D
Dunc
I've got a c# app, and in the HTML in front I have a <div> tag around
some navigation controls, and I want to dynamically change it's ID so
the CSS kicks in and highlights the currently selected option.
Problem is - when you set an ID, it prefixes it with ctl0_ on IIS 5.1
(Windows XP - our dev machines) and ctl00_ on IIS 6.0 (Windows 2003
server - the production machine)
The obvious answer is to create two versions of style stylesheet - one
for dev, one for production. The problem with this is trying to
explain to management why we'd need to modify the CSS outside of
source control every time we deploy it; in short, it's just not going
to happen.
Does anyone know how to override the .net prefix (ctl..), so I can set
the ID of an element with a consistent value?
Code is:
---/ snip /---
<div id="myDiv" runat="server">
<ul>
<li><a href="default.aspx">Home</a></li>
<li><a href="Item1.aspx">Item 1</a></li>
</ul>
</div>
---/ snip /---
string scriptName =
Request.ServerVariables["SCRIPT_NAME"].ToLower(); // get current
script name
string newID = scriptName.SubString(0, scriptname.IndexOf(".")); //
remove extension - home or item1
myDiv.ID = newID; // sets it to ctl0_home or ctl00_home, ctl0_item1 or
ctl00_item1
TIA
some navigation controls, and I want to dynamically change it's ID so
the CSS kicks in and highlights the currently selected option.
Problem is - when you set an ID, it prefixes it with ctl0_ on IIS 5.1
(Windows XP - our dev machines) and ctl00_ on IIS 6.0 (Windows 2003
server - the production machine)
The obvious answer is to create two versions of style stylesheet - one
for dev, one for production. The problem with this is trying to
explain to management why we'd need to modify the CSS outside of
source control every time we deploy it; in short, it's just not going
to happen.
Does anyone know how to override the .net prefix (ctl..), so I can set
the ID of an element with a consistent value?
Code is:
---/ snip /---
<div id="myDiv" runat="server">
<ul>
<li><a href="default.aspx">Home</a></li>
<li><a href="Item1.aspx">Item 1</a></li>
</ul>
</div>
---/ snip /---
string scriptName =
Request.ServerVariables["SCRIPT_NAME"].ToLower(); // get current
script name
string newID = scriptName.SubString(0, scriptname.IndexOf(".")); //
remove extension - home or item1
myDiv.ID = newID; // sets it to ctl0_home or ctl00_home, ctl0_item1 or
ctl00_item1
TIA