Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 2nd, 2006, 10:23 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
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!!!
  #2 (permalink)  
Old August 3rd, 2006, 04:31 AM
Registered User
 
Join Date: Aug 2006
Location: Aosta, , Italy.
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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.