1

why i cannot adding css Content Page in Master Page Asp.Net. i cannot change..

 <asp:TextBox ID="name" runat="server"></asp:TextBox>

then i use css

#name {
width:300px;
height: 300px;
}

but he did not change. anyone can help me resolve this?

1
  • Right-click the textbox in your browser and inspect element (chrome), you will see the ID is no longer "name". It changes when the page renders. Commented Aug 7, 2014 at 12:37

2 Answers 2

2

By default server object ID's aren't rendered exactly the same. You should either use a class instead or set clientidmode to static for the textbox.

If you view the source on the rendered page and look for that textbox, you'll find the ID is probably a few names separated by an underscore.

Here is the same markup with a static client id.

<asp:TextBox ID="name" runat="server" ClientIDMode="static"></asp:TextBox>

Please note that you shouldn't do this for any control that you plan to repeat on a page.

In that case you should use a class.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to use this CSS using Class because When Server control render in page then Their ID is Unique that generate by IIS foloowd by contant page Holder Name

means

<asp:TextBox ID="name" runat="server"></asp:TextBox>
this will genrate 
<input id="ContantPlaceholderName_name" name="ContantPlaceholderName_name"/>

so use class name is better option

2 Comments

thank you for having contributed. I really appreciate. Smeegs has helped me.
yes, that's also good solution but you have to remember their is no duplicate id on page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.