Form controls names are changed when using MasterPage features

G

Guest

Hi all....

I am programming in ASP.NET 2.0 and VS.NET 2005 Beta 2.

I have a MasterPage that provides basic look & feel for my pages.

The main form present in the master page has this element:

<form .... runat="server">
........
<div>
<asp:contentplaceholder id="Contenido" runat="server">
</asp:contentplaceholder>
</div>
</form>

The page that uses the master page has form controls, one of them is named
txtPoliza.

Well.. when I load the page in the browser, all controls changed their name,
for example, using the same example txtPoliza, the field is renamed to
ctl00$Contenido$txtPoliza, of course, affecting JavaScript code I have in the
page.

How can I solve it?
Thanks

Jaime
 
B

Brock Allen

You can't. The IDs are generated basedupon the control's nesting in the server
side control tree. The master is a control itself inserted between the page
and your <asp:Content> controls. If you want to use javascript on the page
to get the ID of the control use the Control.ClientID and dynamically modify
your javascript to use that ID.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top