Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Parameters to Custom Control

Status
Not open for further replies.

baden

Programmer
Feb 6, 2002
125
US
I have created a custom control that has a label who's text is to be changed dynamically when it is used on a page.

The calling page has twoHyperLink Controls:

Code:
<asp:HyperLink id="campaign1" runat="server">Sports Bar</asp:HyperLink>

<asp:HyperLink id="campaign2" runat="server">Drink Specials</asp:HyperLink></td>

I was thinking that I should use an OnClick="SetMsg1" then in the CodeBehind for that HyperLink Control:

Code:
private void SetMsg1(object sender, System.EventArgs e)
{
    WHAT_GOES_HERE???.TextMessage.Text = "this text will be updated when the link is clicked!";
}

private void SetMsg2(object sender, System.EventArgs e)
{
    WHAT_GOES_HERE???.TextMessage.Text = "More text to replace the old text!";
}

Control is located in Controls/TextControl.ascx, where TextMessage is the name of the label to be updated.


Can someone please help me with this?!


Thank you.
 
The "WHAT_GOES_HERE???" bit will just be the name of the custom control that you have given it when you dropped it onto your page.

Also, I'd use a LinkButton rather than a HyperLink control as HyperLinks don't have a click event.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Well, this doesn't seem to be working...

I declared the control in the script page, but not in the Code-Behind...

Can someone give me an example of sending a parameter to a control from LinkButtons - where when clicked, the page updates w/ the new text/parameter that's sent?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top