Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

asked on

simple onclick event handler question

I have a very simple question about event handlers.

I've created a very simple form page with a textbox and image button.

when the image button is clicked I want to pass the value in the text box in a querystring, redirecting to another URL:

Here is my event handler:

protected void SearchImageButton_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("http://search.mysite.com:9000/cgi-bin/query?mss=search&op=x&i=mysite&9=" + the textbox value
    }

The name of my textbox is SearchTextBox

How do I pass that value in my the querystring?
ASKER CERTIFIED SOLUTION
Avatar of mogun
mogun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of -Dman100-

ASKER

I tried to run the page and got the following error message:

ASP.mainmaster.master does not contain a definition for 'SearchImageButton_Click'

Here is the relevant section with the web controls on my masterpage:

<td>
<form runat="server">
Search <asp:TextBox ID="SearchTextBox" runat="server" Height="15px" Width="150px"></asp:TextBox>
<asp:ImageButton ID="SearchImageButton" runat="server" ImageAlign="Middle" ImageUrl="~/images/go.gif" OnClick="SearchImageButton_Click" />
</form>
</td>

And this is the master page code behind:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Template : System.Web.UI.MasterPage
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void SearchImageButton_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("http://search.compasslearning.com:9000/cgi-bin/query?mss=search&op=x&i=CompassLearning&9=" + this.SearchTextBox.Text);
    }
}