This is how to do it:
MyEnum x = (MyEnum)Enum.Parse( typeof( MyEnum ), "SomeString" );
Friday, September 12, 2008
Thursday, June 19, 2008
How to avoid the javascript alert on error when using UpdatePanel with Timer
By default on error during async request UpdatePanel shows an annoying alert messagebox. There is a way to avoid that and handle errors on your own. Here is how to handle errors in ASP.NET AJAX (This is not only for UpdatePanels). The trick is to add handler to endRequest to the PageRequestManager:
<script type="text/javascript">
function EndRequestHandler( sender, args )
{
if ( args.get_error() != undefined )
{
// set error is handled in order to avoid the messagebox
args.set_errorHandled( true );
}
}
function AppLoad()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest( EndRequestHandler );
}
Sys.Application.add_load( AppLoad );
</script>
<script type="text/javascript">
function EndRequestHandler( sender, args )
{
if ( args.get_error() != undefined )
{
// set error is handled in order to avoid the messagebox
args.set_errorHandled( true );
}
}
function AppLoad()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest( EndRequestHandler );
}
Sys.Application.add_load( AppLoad );
</script>
Tuesday, June 17, 2008
UpdatePanel doing full postback when it should not!
I had an UpdatePanel with a Timer for AsyncPostBackTrigger. But although my ScriptManager had EnablePartialRendering="true", my page always got refreshed. The problem was a setting in my web.config. I removed this line:
<xhtmlConformance mode="Legacy"/>
This setting was something that probably I forgot to remove when migrating from asp.net 1.1 to asp.net 2.0.
<xhtmlConformance mode="Legacy"/>
This setting was something that probably I forgot to remove when migrating from asp.net 1.1 to asp.net 2.0.
Subscribe to:
Posts (Atom)
