Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • Last Modified:

LinkButton to set url parameter

I have a form with two panels. The first has a set of five link buttons. Each when clicked needs to set a URL parameter that can be read by the second panel when clicked. This will be a parameter value in the object data source for a data grid on the second panel. This is probably very easy but it is eluding me at this time. Thanks for your help
0
woodje
Asked:
woodje
1 Solution
 
strickddCommented:
I think this should get you started. Simply let the OnClick event set a hidden field that is used as a parameter in the ObjectDataSource.
<asp:LinkButton id="Link1" runat="server" OnClick="Link1_Click" Text="My Link 1"/>
<asp:HiddenField id="ParameterVal1" runat="server" visible="false" /> <!-- visible="false" will only show this field in the encrypted viewstate and will help prevent hack attempts -->
 
 
protected void Link1_Click()
{
     ParameterVal1.Value = "SomeValue";
}

Open in new window

0
 
woodjeAuthor Commented:
That worked perfect. Thanks.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now