Showing posts with label querystring. Show all posts
Showing posts with label querystring. Show all posts

Saturday, March 31, 2012

String to Control.ClientId

Hi.
Is there a way I can convert a string (let's say it's"vw501") sent by a querystring, to a Control's ClientID, like myMultiView.SetActiceView(vw501) ?

I've tried this, which fails:
Dim vName As String = TRim(Request.Querystring("vName"))
myMultiView.SetActiveView(vName)

Regards,

Roy

The FindControl method might help you there. Seehttp://msdn2.microsoft.com/de-de/library/system.web.ui.control.findcontrol.aspx

Make sure you use the FindControl method on the Control your views are nested in. Say if your Views are inside a Form named form1, like so:

myMultiView.SetActiveView( form1.FindControl(vName) )


Thanks a lot :-)
It works!

Roy

Tuesday, March 13, 2012

Struggling with querystring calling in formviews

Hi,

I am having trouble getting querystrings to show up in textboxes in a formview control. I know you have to dig deeper to find the textboxes, but I thought I had done so, but it doesnt seem to work at the moment..

I am currently getting:

'Buyers_Shippingdetails' does not contain a definition for 'SellerusernameTextBox'

referring to:

Line 28: this.SellerusernameTextBox.Text = Request.QueryString["sellername"];

as an error.. my code is:

protected void FormView1_Load(object sender, EventArgs e)
{
TextBox SellerusernameTextBox = FormView1.FindControl("SellerusernameTextBox") as TextBox;

TextBox NameitemTextBox = FormView1.FindControl("NameitemTextBox") as TextBox;

TextBox prodIDTextBox = FormView1.FindControl("prodIDTextBox") as TextBox;

this.SellerusernameTextBox.Text = Request.QueryString["sellername"];
this.NameitemTextBox.Text = Request.QueryString["itemname"];
this.prodIDTextBox.Text = Request.QueryString["proID"];
}
}

Thanks if someone can help! I am stuck with the same problem on a couple of pages.

Any advice is welcome!

Cheers,

Jon

First off, remove the "this" qualifier from in fron tof your variables. These are method-level variables and don't require qualifiers. Also, I'd recommend you move your code to the FormView.DataBound event.

protected void FormView1_DataBound(object sender, EventArgs e){TextBox SellerusernameTextBox = FormView1.FindControl("SellerusernameTextBox")as TextBox;TextBox NameitemTextBox = FormView1.FindControl("NameitemTextBox")as TextBox;TextBox prodIDTextBox = FormView1.FindControl("prodIDTextBox")as TextBox;if (SellerusernameTextBox ==null) {return; }if (NameitemTextBox ==null) {return; }if (prodIDTextBox ==null) {return; }SellerusernameTextBox.Text = Request.QueryString["sellername"];NameitemTextBox.Text = Request.QueryString["itemname"];prodIDTextBox.Text = Request.QueryString["proID"];}

Just the trick.

Thanks alot, as always.

Jon