Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to display parameter passed to a page in a textbox control

Reply
Thread Tools

How to display parameter passed to a page in a textbox control

 
 
Morris Neuman
Guest
Posts: n/a
 
      04-09-2007
Hi,

I have a gridview control on a page that has as its column a hyperlink
field. This hyperlink field opens another page and passes a parameter.
The hyperlink field has values as follows:
DataNavigateUrlFormatString = ManageUser-MBoxes.aspx?User={0}
DataNavigateUrlsFields = UserName.
The gridview is bound to an SqlDataSource control which returns the value of
UserName.

I want to display the value of the selected UserName field passed in the
parameterwhen the linked page is open in a TextBox control.

How do I bind the value of the TextBox control the the parameter passed to
the page via the hyperlink?

Any help would be appreciated.
--
Thanks
Morris
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      04-09-2007
Hi Morris,

As for the "bind url parameter from linked page to textbox" issue, I think
you can consider the following means:

1. If using code behind is acceptable, you can simply put the following
code in Page_load event to attach the querystring parameter to the Textbox.
e.g.

===============
protected void Page_Load(object sender, EventArgs e)
{
txtUsername.Text = Request.QueryString["User"];
}
===============

2. Another approach is using databinding expression, e.g.

<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtUsername" runat="server" Text='<%#
Request.QueryString["User"] %>'></asp:TextBox>

but you need to explicitly call "DataBind" method of the textbox to trigger
the databinding:

protected void Page_Load(object sender, EventArgs e)
{
............
txtUsername.DataBind();

}



3. Another means is use the new feature of ASP.NET 2.0, you can build a
custom expression builder. This can help you embed normal codesnippet in
your ASP.NET server control's tag(attribute). Here is a good blog article
detailedly describe this:

#The CodeExpressionBuilder
http://weblogs.asp.net/infinitiesloo...odeExpressionB
uilder.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.





 
Reply With Quote
 
 
 
 
Morris Neuman
Guest
Posts: n/a
 
      04-10-2007
Hi Steven,

I used option 2 and it worked well. Thanks for your help.
--
Regards,
Morris


"Steven Cheng[MSFT]" wrote:

> Hi Morris,
>
> As for the "bind url parameter from linked page to textbox" issue, I think
> you can consider the following means:
>
> 1. If using code behind is acceptable, you can simply put the following
> code in Page_load event to attach the querystring parameter to the Textbox.
> e.g.
>
> ===============
> protected void Page_Load(object sender, EventArgs e)
> {
> txtUsername.Text = Request.QueryString["User"];
> }
> ===============
>
> 2. Another approach is using databinding expression, e.g.
>
> <form id="form1" runat="server">
> <div>
> <asp:TextBox ID="txtUsername" runat="server" Text='<%#
> Request.QueryString["User"] %>'></asp:TextBox>
>
> but you need to explicitly call "DataBind" method of the textbox to trigger
> the databinding:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> ............
> txtUsername.DataBind();
>
> }
>
>
>
> 3. Another means is use the new feature of ASP.NET 2.0, you can build a
> custom expression builder. This can help you embed normal codesnippet in
> your ASP.NET server control's tag(attribute). Here is a good blog article
> detailedly describe this:
>
> #The CodeExpressionBuilder
> http://weblogs.asp.net/infinitiesloo...odeExpressionB
> uilder.aspx
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
I have one ASP.NET Page. It's for display customer information. Now I want this page to handle the function "Edit" and "Display", Is it possible? Benny Ng ASP .Net 1 01-04-2007 08:00 PM
how to transfer textbox value from .net page to html page textbox? Steve Javascript 4 02-07-2006 06:30 PM
Command line options: using an [option: parameter] without a parameter passed to it soren625 Perl Misc 10 12-28-2005 09:26 PM
Re: VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail??? S. Justin Gengo ASP .Net 0 07-16-2003 06:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57