Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2006, 10:23 AM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Master pages &server control ID - asp.net 2.0

Hi,

I am trying to use couple of server controls in my master page and I need to identify the same at the client side(javascript).

But in ASP .NET2.0 the server controls are appended with "ctl00_ctl00_" to the control id.

for example if i set the contol id as

<asp:HiddenField ID="hidcontrol" runat="server" />

and try to get the control value using js as

var controlvalue=document.getElementById("hidcontrol") .value;

IN ASP 2.0-Master pages ,the control id will be renamed to "ctl00_ctl00_hiddenevent"

<input name="ctl00$ctl00$hidcontrol" type="hidden" id="ctl00_ctl00_hidcontrol" >

In this case ,How will I access the control value dynamically at the client side.

Please help.I am not able to move forward as i need the value to be accessed from the client side for sure.

NB:Saw couple of discussion threads where its suggested to get the control id by the following way.;

var controlvalue=document.getElementById("<%=hidcontro l.ClientID%>").value;

But I am not able to get it.Am i missing something.PLease HELP

One more query;Is there anyway to force a master page to retain the name of the form as
programmed instead of changing it to aspnetForm?

Thanks in Advance!!!
 
Old August 3rd, 2006, 04:31 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The suggestion you found works in legacy ASP, in .Net you should write instead:

var controlvalue=document.getElementById("<% Response.Write(hidcontrol.ClientID); %>").value;

I hope it helps.

Lucio






Similar Threads
Thread Thread Starter Forum Replies Last Post
will flash work in master pages of asp.net kalyan141142 ASP.NET 2.0 Professional 2 November 21st, 2007 11:21 AM
ASP.Net & SQL Server chenwf2006 ASP.NET 2.0 Basics 0 December 17th, 2006 03:54 AM
Can i have .ASP & .ASPX pages in same .net Appli? vijaykumartaduri Classic ASP Basics 3 December 14th, 2006 09:42 AM
Indexing Service and ASP.NET 2.0 Master Pages thenoseknows ASP.NET 2.0 Professional 1 September 15th, 2006 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.