469,927 Members | 1,454 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Form controls names are changed when using MasterPage features

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
Nov 19 '05 #1
1 3109
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
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


Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ray Cacciatore | last post: by
2 posts views Thread by Mark | last post: by
3 posts views Thread by rgparkins | last post: by
4 posts views Thread by Joe | last post: by
9 posts views Thread by dhtml | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.