Skip Navigation Links Home Blogs

cubido > Blogs > Posts > Get control value through Request.Form using masterpages in ASP.NET 2.0
July 30
Get control value through Request.Form using masterpages in ASP.NET 2.0

I often have to access controls in the Page.Init event, what is not possible through the default access method (this.MyControl) but only through the Request.Form collection using the controls name . When using masterpages, controls cannot be accessed directly using their IDs given in the ASPX markup. Instead you have to use a little function like the one stated below to get the “real” client name:

 

String getClientName(Control ctrl)
{
    
String result = ctrl.ClientID.Replace("_", ":");
    
result = "_" + result.Substring(1, result.Length - 1);
    
return(result);
}

 

You can the easily get the value of the control by using

 

Request.Form[getClientID(this.MyControl)])

Comments

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

it's not always the underscore. A dollar sign might also be there.<br>Eg. ct100$ContentPlaceHolder$myControlName
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

You can avoid all the round about methods above, by using Server.Transfer("whateverPage.aspx"); in your OnClick event. You might (rare) have to look out for any objects you don't want transfered in your viewState and make alterations before the transfer, perhaps by storing and retrieving values from the Context.Items collection (or similar method) - Asame Obiomah
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

Want more coding details and information
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

eh, use uniqueID instead! that is the controls ID as seen in the source of the generated page
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

what about using dynamic control array with this method
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM

Re: Get control value through Request.Form using masterpages in ASP.NET 2.0

Furthermore there are two chapters at the end of how one can use the adapter for sending and receiving messages inside a normal .<a href="http://www.certpaper.com/646-223.htm">646-223</a> NET application. But LOB Adapters are planned to be used in BizTalk as well, so the question is how these new adapters can be included in BizTalk Server R2. This article shows how the EchoAdapterV2 can be used as BizTalk Receive Location which covers some basic information about the usage of LOB Adapters in BizTalk in common – even if this sample does not do very useful stuff it bridges the gap in the tutorial between just developing a LOB Adapter and really using it in BizTalk Server.<br><br>The requirements <a href="http://www.certpaper.com/650-251.htm">650-251</a> for the sample for receiving a message from the EchoAdapterV2 are rather simple. In the EchoAdapter tutorial an inbound operation (OnEchoReceive) is created, which checks a specified directory for incoming files (*.txt) and returns the name and the size of the file. So to test the receive side of the adapter it should send the received message (filename and size) to a BizTalk Orchestration and dump <a href="http://www.certpaper.com/70-271.htm">70-271</a> this message back to a file on the disk. Quite simple for the moment …<br>
CUBIDO\p.kirschnerNo presence information on 3/17/2010 10:01 AM
 

 Add Comment

 
Titel  
Your Name:  
Your Comment:  
Your EMail:  
*