Events

R

Robert Smith

Hi, I have a web form page with a control on it. However I would like to know
when the Search button on the control has been clicked.

On my parent form I have the following


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link type="text/css" rel="stylesheet" href="main.css" />

</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:Search ID="Search1" runat="server" />

</div>
<asp:Label ID="lblSearchString" runat="server"></asp:Label>
</form>
</body>
</html>

On My Search Control on the main form I have



public partial class Search : System.Web.UI.UserControl
{


string _searchstring;

public event ClickedEventHandler Clicked;

public string SearchString
{
get { return _searchstring; }
set { value = _searchstring; }
}

protected void Page_Load(object sender, EventArgs e)
{


}

protected void lnkSearch_Click(object sender, EventArgs e)
{
_searchstring = this.txtSearch1.Text + this.txtSearch2.Text;
OnSearchClicked();
}


}

I want to be able to detect on the parent form when the lnkSearch_Click
event is called, so that I can pick up the value of SearchString .

Thanks in advance

Robert
 
B

bruce barker

read the chapter on delegates and events. in the lnkSearch_Click routine,
fire the event "Clicked" you defined. in the webform, attach a handler to the
public event.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top