asp.net disabled jquery dialog modal button after postback - jquery-ui

I'm using jQuery Dilog Modal in ASP.NET page but when the page do postback the button that open the dialog modal loses the jQuery behavior...
I tested the button inside and outside of UpdatePanel, but I got the same error...
How can I maintain the jQuery after postback?

Try wiring up your button inside pageLoad() instead of $(document).ready(), which is native to .NET and will fire on each postback.
function pageLoad(sender, args)
{
$('#button').click();
}
Beware that pageLoad() is not a permanent replacement for $(document).ready() when using ASP.NET, since they behave very differently, but in this case it just might solve your problem.

Related

Automatically open a popup on load with MVC

I have a page with ASP.net MVC 5 with Bootstrap in that displays a table of many records. I have a popup that open when I click on a button that is located on each row, basically some CRUD. This works fine.
What I would like to do now is when a user enter a specific URL (like site/Proof/LoadSpecific/342) to open the page as usual, but also show the modal as if I clicked on a specific button.
I am faily new to MVC, JQuery and web in general. How would I do this ?
Thanks
If you're using bootstrap modals you can use the following functions (assuming you have the bootstrap js and jquery scripts included as well)
assuming myModal is the id of your modal element:
$('#myModal').modal('toggle'); //toggles the shown/hidden state of the modal
$('#myModal').modal('show'); //shows the modal
$('#myModal').modal('hide'); //hides the modal
so you would include a script on your page that shows the bootstrap modal on load such as the following:
$(function() {
$('#myModal').modal('show');
});
Here's a link to the bootstrap 3.3 documentation which has a good deal more information on these components and how you can use them.

JQuery Mobile ajax enabled causing client side validation not working

I am learning the JQuery Mobile framewrok and is using VS 2013 for my new project. I created a MVC 4 JQuery Mobile project. From the project I got out of the box, I click on the Login link and on that login page, I click on the Login Button, it shows the expected error messages. I want my project to be ajax enabled so I set the $.mobile.ajaxEnabled = true; and debug in VS, it hits the break point I set in the Login action in the AccountController so the client-side validation didn't work and got to the post on the server-side.
Is it by design that I can't use the built-in client-side validation when ajaxEnabled is set to true? Or is there some settings that I need to set? I need my project to be jax enabled and would like to use the built-in client side validation if possible and don't have to write custom jquery validation code.
Found the answer. add the below code to the on pageshow event
$.validator.unobtrusive.parse(".ui-page-active form");

What causes Ajax.BeginForm to go crazy when Bootstrap Modal Divs are accidentally kept within the parent Form

Setup
I had an MVC View containing a Partial View that had an Ajax.BeginForm.
This was in turn triggering bootstrap modal pop ups for subsequent operations.
I enabled Unobtrusive validation and included Unobtrusive Ajax script references.
All my scripts were of the latest JQuery version.
Mine was an ASP.NET MVC5 application running on .NET 4.5 framework with razor views.
Problem
All hell broke loose when I ran this web application.
1)Bootstrap backdrop remained after modal was hidden.
2)Form was submitted twice
3)Submit button was rendering the Json result directly on the browser instead of sending it to onSuccess designated method.
Troubleshooting this from scratch, I realized that I had included the Modal dialog DIVs (the one which we refer in the data-target attribute) inside the Ajax.BeginForm of my partial view (thinking that those are anyways being triggered from within the partial view).
Keeping them out of the form resolved the issue.
Why can't the Modal Divs be kept within the Ajax.BeginForm? Is this caused due to the way the Bootstrap treats and invokes the Modals?

How to get Popup window in struts2 without using javascript code

How to get an pop up window in a struts2 program , I am not using any JavaScript code. Is it possible to get a pop up window using Struts2 code
If you want to display a popup box then you could use javascript to do it. Also its WAY EASIER to do it using javascript.
It would be something like this -
alert("This text will be displayed in the alert box!");
As with struts2 , you could use javascript by adding the javascript inside the <script> tag.
Hope this helps!
Cheers :)

jQuery Mobile and ASP.NET WebForms

I'm using jQuery Mobile 1.1 and .NET 3.5 WebForms. I've got a few dropdowns that I populate with choices in the Page_Load after checking !Page.IsPostBack. When using JQM, the UpdatePanel with these dropdowns comes back with all of the dropdowns empty. I feel like this is something with ViewState because it's all of the controls that were previously filled by the code. The dropdowns that are filled out in the ascx don't have the same problem.
The only thing in my mobileinit is:
$.mobile.ajaxEnabled = false;
jQuery Mobile, asp.net web forms and update panels simply don't work with one another:
JQueryMobile dialog shows twice because of a postback
You may also be having issues related to the select menu not refreshing when changes occur within the update pannel. Consider manually refreshing that:
$("#mySelectMenu").selectmenu("refresh");

Resources