Events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Um9iZXJ0IFNtaXRo?=

    Events

    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>Untitl ed 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="lblSearchSt ring" runat="server"> </asp:Label>
    </form>
    </body>
    </html>

    On My Search Control on the main form I have



    public partial class Search : System.Web.UI.U serControl
    {


    string _searchstring;

    public event ClickedEventHan dler Clicked;

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

    protected void Page_Load(objec t 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

  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: Events

    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)


    "Robert Smith" wrote:
    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>Untitl ed 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="lblSearchSt ring" runat="server"> </asp:Label>
    </form>
    </body>
    </html>
    >
    On My Search Control on the main form I have
    >
    >
    >
    public partial class Search : System.Web.UI.U serControl
    {
    >
    >
    string _searchstring;
    >
    public event ClickedEventHan dler Clicked;
    >
    public string SearchString
    {
    get { return _searchstring; }
    set { value = _searchstring; }
    }
    >
    protected void Page_Load(objec t 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
    >

    Comment

    Working...