473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

asp:button question

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
Jun 27 '08 #1
3 1012
"hal" <hl*****@gmail.comwrote in message
news:c5**********************************@y38g2000 hsy.googlegroups.com...
Is this possible to do, and if so what am i missing?
<asp:ImageButton ID="btnSubmit" runat="server"
ImageUrl="~/Images/signin_btn.gif" Width="103" Height="33"
OnClick="btnSubmit_Click" OnClientClick="SetImage();" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
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

Jun 27 '08 #3
"hal" <hl*****@gmail.comwrote in message
news:d1**********************************@x41g2000 hsb.googlegroups.com...
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?
Slightly puzzled... Do you want this control to have any server-side
functionality or not...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Frag | last post by:
Hi guys, I searched around without any clear answer. Tons of stuff, but nothing concrete. I am trying to call this Javascript function: function ButtonClicked() { alert("The button has...
0
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following shopping cart (basket view). However, Delete button in my datagrid doesn't fire any events. Does anyone know why? (It's a user web control) <%@ Control...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
1
by: Timothy V | last post by:
Hi, How do i make an asp:Button execute its Click event when the Enter key is pressed? Thanks in advance, Tim.
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
7
by: Lam | last post by:
I want to dynamic generate a asp:button in C# class, not in the HTML code so that it can call the methods in the c# class, I try to use "Response.Write("<asp:button...>") it didn't show the button...
1
by: CharlesA | last post by:
Hi folks, first off, I'm using Framwork 1.1 with ASP.net and C# I'm trying to do something quite basic and can't figure out why it won't behave without going into massive details I want a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.