asp:button question

H

hal

Is it possible when an asp:button is clicked I can have the button use
javascript client side code and fire the click event for the button
for server side code? Code below is an example of what i'm trying to
do:

<script type="text/javascript">

function SetImage()
{
alert("Testing");
}

</script>

<asp:ImageButton ID="btnSubmit" runat="server" ImageUrl="~/Images/
signin_btn.gif" Width="103" Height="33" OnClick="btnSubmit_Click" />

protected void btnSubmit_Click(object sender,
ImageClickEventArgs e)
{
//Doing Stuff
}

I've tried playing around with this code in Page_Load and can't get it
to work:

btnSubmit.Attributes.Add("onclick", "SubmitLoginForm()");

Is this possible to do, and if so what am i missing?

Thanks
 
H

hal

Thanks that works fine when the page is posting back to itself. In
javascript code i have the page re-directing somewhere else, and with
your changes it still does hit the server side code. I also tried
testing this without the javascript code doing the re-direct and
putting a postbackURL on the button and that also did not hit the
server side code.

Any other suggestions?

Thanks
 

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

Top