asp button and modal - asp.net

So i have this button:
<asp:Button ID="Buttonid" runat="server" Text="View" BorderStyle="None" OnClick="Button_click_event" data-toggle="modal" data-target="#myModal"></asp:Button>
but then clicking the button will not toggle the OnClick Event, it will just show the modal.
But if i remove the data-toggle="modal" data-target="#myModal". The onclick event will work, but obviously the modal will not popup anymore.
Help please. Thanks

The script that is controlling your model more than likely stops the regular functions of the button so will stop it posting back which will stop the event handler from being fired.
To get both client side and server side to fire you'll have to post back and then display the model when the page reloads.

Related

Asp.net Button Firing Other Button's Event

I have a set of options on an ASP.net page where the user may open up one of two lightboxes - either the "Add" lightbox or the "Edit" lightbox.
Each one has a small form for the user to fill out, and then they can hit a button at the bottom of the lightbox to hit submit.
I have the buttons set up within the lightboxes like so:
<asp:Button Id="btnSubmitAdd" runat="server" Text="Submit" OnClick="btnSubmitAdd_Click" />
... then later in the other lightbox...
<asp:Button Id="btnSubmitEdit" runat="server" Text="Submit" OnClick="btnSubmitEdit_Click" />
When i click the "Add" lightbox's submit button, everything behaves just fine.
When i click the "Edit" lightbox's submit button however, it fires "btnSubmitAdd_Click" instead of its own "...Edit_Click" event!
I have checked and re-checked all of the names and events and everything is set up correctly. Anyone have any ideas why this is happening?
Thanks to #MikeGuthrie for leading me down the correct path!
The issue seems to be with asp.net defaulting buttons to type "submit" which submits the entire form, and apparently that means it simply hit the first button's event before the second.
I added have modified the buttons like so and things are working now:
<asp:Button Id="btnSubmitAdd" runat="server" Text="Submit" OnClick="btnSubmitAdd_Click" UseSubmitBehavior="false"/>
<asp:Button Id="btnSubmitEdit" runat="server" Text="Submit" OnClick="btnSubmitEdit_Click" UseSubmitBehavior="false"/>

Submit button stops working after postback in IE11

Problem:
Sometimes submit button stops working after postback in IE11. It's
clickable, but it doesn't trigger any event. There is no script or
server side errors. Even the right click menu doesn't show on button.
If clicked somewhere on page it starts to work normally.
Button is general ASP.NET button
Server side:
<asp:Button ID="btnSave" runat="server" Text="Save" SkinID="Button82" OnClick="btnSave_Click" />
Client side:
<input name="ctl00$cphMain$Substitution$btnSave" class="button82" id="cphMain_Substitution_btnSave" type="submit" value="Save">
Any solutions?
For now I solved it using this in postback:
ScriptManager.RegisterStartupScript(Page, this.GetType(), "Refocus", "RefocusIE11()", true);
It calls function after postback, that refocuses on next element. This makes button to work again.

disabling asp button onclick prevents event from firing

I'm trying to disable an asp button when it is clicked on the client side.
<asp:Button runat="server" ID="btnSubmit" Text="Save" class="Button" OnClick="btnSubmit_Click" CausesValidation="false"></asp:Button>
<script type="text/javascript">
$("input[type=submit],button").click(function (){$(this).attr("disabled", "disabled");});
</script>
when the button is clicked it does post back to the page_load , but it won't go to the btnSubmit_Click method. If I remove the jquery that disables the button it makes it from the page_load to the btnSubmit_Click method.
It seems when the button is disabled from the jquery it is no longer able to wire up to its event. Anyone have any ideas how I can disable the button client side, and still make it to the specific onclick event method?
This is resolved (Yuriy answered), the issue was that I needed to put the disabled code within the form.submit client side code. If not the disabled button was not firing its click event, yet it was still posting back, just not going to the onclick method.
solution:
$('#Form1').submit(function(){ $("input[type=submit],button").click(function (){$(this).attr("disabled", "disabled");});

how to opacity the asp.net page on button click , till procees get complete

how to opacity the asp.net page on button click , till procees get complete of respective button.
Can anyone help me ?
If it's a regular postback, use client side javascript to disable the button before the actual postback happens.
<asp:Button runat="server" ID="myBtn" OnClick="YourServerSidePostBack"
OnClientClick="document.getElementById('<%= myBtn.ClientID %>').disabled = true;" />

Onclick not added until after Postback

I have the following:
<asp:Button id="SubmitButton" Text="Submit" runat="server" OnClientClick="Do();"
OnClick="SubmitButton_Click"/>
When the page is first rendered, I go to the view source in my browser and see that the onclick="Do();" is not added to my submit button tag. But when I do a post back, and do the view source again, the onclick is added to the submit.
Why would the onclick not be there on the first request?
At least on my machine, I can see OnClick event on both request.

Resources