Alternatives to modal popup extender in asp.net? - asp.net

I have a modal pop extender that has a user control in it, I use it in several forms in a
ASP.NET 4.0 project.
I am not very happy with the js code that it produces and the mess in the markup :/
So, any worthy alternatives that can be controlled from the codebehind easily :) ?

Having been down the road of Ajax Control Toolkit, I would recommend moving on to jQuery or some other javascript framework. While I understand the desire to "control it from codebehind," because it seems easier at first, trying to wrap client-side functionality in a server-side control usually is more trouble than it's worth.
Even in the simplest case, the the amount of javascript code needed to create a modal popup in jQuery (e.g.) is less than with Ajax Control Toolkit MPE. For example, I like the jQuery plugin SimpleModal. The code to turn a div into a modal popup using SimpleModal with default options is this:
<script type="text/javascript">
function showPopup() {
$('#<%=popupDivID.ClientID %>').modal({ appendTo: '#aspnetForm' });
}
</script>
Then you can just add that function to a click event, for example. And it's about a thousand times more flexible.
If you just don't like embedding javascript in your markup files, you can still technically control this all from codebehind by using ScriptManager to register the scripts and add events to controls.

Have you looked at the Ajax Control Toolkit on CodePlex. Ajax Control Toolkit It has several very useful controls that are very easy to implement. The toolkit includes a modal popup control as well as a popup control. In the link I gave you are all the instruction on how to download and use the toolkit.
Another option if you have access to it is Telerik controls. Their Ajax controls include what they call a radWindow which also works very well. You can read about it here. The drawback to Telerik is it is quite expensive.
I have used both and they work very well.

Use jQuery Dialog UI as this would likely give you the best supported option. It supports modal behavior.

Related

Any suggestions for a nice ASP.NET Ajax tooltip?

I am looking for a nice tooltip control (with delay) in ASP.NET AJAX. I know there are many nice Javascript libraries out there, but since I am already using ASP.NET AJAX, I may just as well use that.
An "oldie-but-goodie" that I have used many times for tooltips would be overlib It's quite nice, VERY flexible and can be used independent of any particular AJAX platform.
Telerik seems to have the mojo in this area, but since I assume you're looking for free...
The nicest ones appear to be jQuery plugins, like this one:
http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html
There is also this ASP.Net AJAX TooltipExtender:
http://weblogs.asp.net/cjdevos/archive/2008/03/29/asp-net-ajax-tooltipextender.aspx
I was able to make a pretty nice balloon popup using the PopupControlExtender from the ASP.Net AJAX Control Toolkit. You can specify the target control to invoke the popup, the control or div that contains the popup content, and you can also dynamically populate the content using an AJAX callback to a service method.
I recommend:
Pure JavaScript with Ajax capability:
Menucool Tooltip
ASP.NET version, with Ajax Load On Demand:
Menubasic Tooltip
If you don't need the Ajax feature, Menucool has a very easy-to-use CSS tooltip either.
One option is WZ_Tooltip. Most tooltips are basic javascript; you should not expect to find much in the way of .NET integrated tooltips, since there is not much reason to use it rather than just using a javascript.

Ajax replacment for JavaScript prompt command

The JavaScript prompt command
prompt("sometext","defaultvalue");
is a useful way to easily prompt the user to provide a value. But it can't really be a part of any polished web 2.0 application (The dialog looks horrible).
Is there any existing component to display a modal dialog that will prompt a user for a value? I can use a pure JavaScript solution or anything developed for ASP.NET
I'm sure there are a lot of things that fit the bill in of the most javascript frameworks out there. For instance, there are a few out there for jQuery e.g. Impromptu or if you want something specifically for ASP.NET then there are few things you could probably use from the ASP.NET Ajax Control Toolkit such as the Modal Dialog or of course, you could roll your own!
You can code your own solution with a div containing an input field and a button and some JavaScript to show/hide the div.
This will not block the JavaScript code flow so you will have to set a callback function on the Close/Ok button.
If you are ok with JS libraries almost all of them have a Dialog widget.

Automatically Refresh a web user control

How can we refresh a web user control automatically without a page postback in asp.net 2.0? i have tried meta tags in controls head tag but it also refreshes the whole page.
You could try implementing a little bit of the ASP.NET AJAX Framework into your app and wrapping that control in an UpdatePanel. It will work with .NET 2.0
Edit: Here is a quick link to a tutorial on using the ASP.NET AJAX UpdatePanel: http://ajax.net-tutorials.com/controls/updatepanel-control/
And here is the official introduction page from the ASP.NET website: http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx
User Controls are server based controls. Your only option might be some type of javascript but depending on what you are try to accomplish, unlikely.
There are several ways to do it and it depends on what your control is made of.
One of the easiest ways to do it is to wrap the control in an UpdatePanel and then use a Timer control to just update that UpdatePanel. But that might be expensive in terms of viewstate.
Another option is to use something like Jquery and a Javascript timer to count down and then refresh using static page Methods (http://encosia.com has examples).

jQuery Validation plugin and ASP.NET validators Web Forms

I would really like use the jQuery Validation plugin in my ASP.NET Web Forms application (not MVC).
I value jQuery validation for the Richer UI experience I can provide the end user and I have some requirements to highlight the invalid fields using a red border (css).
I value asp.net validators because they run the validations not only on the client but on the server so that I don't open various security vulnerabilities to any user who is clever enough to turn off javascript in their browser.
So I am looking for a nice clean way to integrate these two technologies.
The best I can come up with is to have all ASP.NET validators set to enableclientscript=false and repeat the validation rules on the client in jQuery and on the server as asp.net validators but I can already see some challenges with this approach.
In the end I found the lowest friction way to achieve highlighting with asp.net validators and jquery was not to use the jQuery Validation plugin but to use the simple line of jquery which follows (note that the exact syntax will vary depending on how you layout your forms):
<script type='text/javascript'>
$("input[#type=submit]").click(function() {
$('span.validationerror:hidden').parent().parent().find('input').removeClass('inputError');
$('span.validationerror:visible').parent().parent().find('input').addClass('inputError');
});
</script>
You can use asp.net and jquery validators together with no problem... even on the same control... you just need to set CssClass for the control so that jquery can find it... and then you add OnClientClick="return $('#aspnetForm').valid();" to your submit button(s).
Be sure and include the usual jquery library and jquery.validate.js and add a document ready function of course, etc.
This might help!
http://www.delphicsage.com/home/blog.aspx?d=205
If you are serious about validation, I would look into something like Peter Blum's validators (http://www.peterblum.com/Home.aspx) as they should be able to do everything you want and more. They don't use JQuery, but remember the whole point of JQuery is to save developer time - the end user doesn't know or care whether you are using JQuery or not if the overall effect is the same.

How do I control the amount of JavaScript Ajax Control Toolkit spits out?

With the Ajax Control Toolkit, one can easily drag and drop all types of great extender onto controls, but they register a boatload of JavaScript to do it.
How do I control this?
If the ScriptManager is in the MasterPage, is there anyway to control the loading of a script on one page that isn't in another?
For example: calendar extender is on one page, but the script for it gets loaded on every page that is a child of the master page.
I'd love to have an answer to this, as well.
The toolkit's blind insertion of javascript,
without regard to best practices, has led our
devs to make ridiculously large pages.
The whole POINT to the toolkit is to make design
easy, but now we have to refactor our entire UI,
because of the 'ease' it provided. We're sending
HUGE pages out, which we cannot cache.
Consider moving away from the Ajax control toolkit. The huge JavaScript load is the reason why we are moving away from it. You should consider a library such as jquery.

Resources