Using jQuery BlockUI Plugin with ASP.NET Input Form15 Jul 2009
I was recently working on an ASP.NET WebForm project where it made sense to use a modal dialog to confirm choices, to ask for additional information, etc…
I’ve used the jQuery BlockUI Plugin before and I’ve always thought it provided a good mix of nice features as well as extreme customization.
Ii went ahead an implemented BlockUI across the application and was satisfied on how it looked & felt, but I noticed some weird behavior on one of the modal screens. I had a screen that had numerous input controls (textboxes, dropdownlists, etc…) and when I posted back my results all of the input controls were blank!
Ahh, what do I do? Where are my updated input values?
- Check to make sure I wasn’t re-initializing the input controls on PostBack
- Investigate that I didn’t turn off viewstate by accident & make sure I wasn’t using dynamic controls
After those steps I was still confused and frankly wasting a lot of time with something I thought would be very quick.
To make a long story short, it was BlockUI that was clearing the input controls on PostBack!
So, I created a fresh demo application to replicate the issue and started investigating.
The following code shows how to recreate the issue and how to resolve the issue.
The issue is more obvious if you had used an in the above code snippet instead of an
So, the solution that works is…
- Attach a jQuery click event to your LinkButton
- Prevent the default click behavior of the LinkButton
- Unblock the modal window to restore default behavior of input form
- Add an onUnblock event to the modal window and evaluate the LinkButton’s href