asp.net - How to disable/override naming container's ID generation of Content page's control id's -


we have existing asp.net web application want convert using masterpages. in process of doing this, found html id's generated html elements prefixed contentplaceholder's id. , can expected when set contentplaceholder's clientidmode=static. since have lot of existing client side scripts make use of id's, part breaks when use masterpages, , quite big job run through our javascript make sure call javascript using control.clientid, lot of hardcoded.

is there way disable prefixing? can succeed doing this, if create every control setting clientidmode=static, again prefer settings once, ensure controls have clientidmode=static. possible? or possible override namingcontainer of contentplaceholder?

the platform .net 4.0

(after fixing above problem clientidmode=static in web.config described in answer below), have bumped problem "name" attribute automatically generated, , not set whatever before introduced masterpages. gives me problem existing server code, has many request.form[]. idea best practice here solve problem?

thanks jihad

you can have clientidmode @ page level:

<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" clientidmode="static" %> 

masterpage level:

<%@ master language="c#" autoeventwireup="true" codefile="masterpage.master.cs" inherits="masterpage" clientidmode="static" %> 

and web.config level (making pages inherit behavior):

<system.web>     <compilation debug="true" targetframework="4.0"/>     <pages clientidmode="static"></pages> </system.web> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -