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!

onclick on an image

Status
Not open for further replies.

jimberger

Programmer
Jul 5, 2001
222
GB
Hello,

I am trying to create a image that has an onlick event that runs my ASP.NET function submit_search. When a place an onclick on an image it tries to look for a javascript function called submit_search. I've also tried using ASP:Imagebutton but I can't get this to work either?

any ideas anyone?
thanks

jim
 
There are no handlers of the control Image. You can only define the ImageUrl whenever you want, the alignment etc..

Instead, delete it and drag an ImageButton control. This has event handlers such as onClick()
 
>>I've also tried using ASP:Imagebutton but I can't get this to work either?


hmm, can i have the code???

Known is handfull, Unknown is worldfull
 
Hi,

I've tried

<asp:ImageButton ID="submitsearch" runat="server" ImageUrl="images/search_button.gif" OnClick="Submit_Search" />


and in my Submit_Search function I have


Session["sDay"] = startday.SelectedValue;
Session["sMonth"] = startmonth.SelectedValue;


Server.Transfer("results.aspx");


but the page dosen't transfer to results.aspx

any ideas?
thanks for your help
 
did you try having a Response.Write() in the sub???

Known is handfull, Unknown is worldfull
 
In the design view double click the image button and add there the code. The default hendler is the _onClick event.

You messed up javascript functions and asp.net function.

In javascript:
<script language=javascript type=text/java>
function Submit_Search(// arguments ?)
{
//
}
</script>

To call this you add to the button or whatever (html code) ... onclick="Submit_Search();"

In ASP.NET, when using VB.NET, your code do not return something so it is a Sub (Public, shared, private ...)

Else it is a function:
<ScopeType> Function NameOfFunction('args ?) As <TypeReturned>
' one return must be executed
End Function


Sub Submit_Search() 'Private
Session["sDay"] = startday.SelectedValue;
Session["sMonth"] = startmonth.SelectedValue;

Server.Transfer("results.aspx");
End Sub

Call it in the click event handler by just typing the sub's name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top