Regular expression validator firing after postback in asp.net

by abhilashca 22. April 2012 08:52


As usual, I’s really surprised to see what had happened when I attach a regular expression validator to one of my fileupload control. The regular expression validator was firing after every successful fileupload. Yup! The solution is way too simple. Simply, set the IsValid property of the regular expression validator to true.

protected void btnAddDocument_Click(object sender, EventArgs e)
{
    //
    // your logic comes here
    //
 
    regexvalUploadDoc.IsValid = true;
}

That’s it.

 

Categories: ASP.NET

ASP.NET Menu rendering issue in Google Chrome

by abhilashca 27. March 2012 21:09

 

Now, that was weird!

Surprisingly, I jumped into a rendering issue with ASP.NET menu in Google Chrome and I observed following glitches:

  1. Sub-menu items were not displaying on hovering over the main menu (say Products)
  2. When I select the main menu item (Product), the respective sub-menu items are displayed horizontally, instead of listing vertically (on hover)

Here goes a sample screenshot

menu_issue

The solution is to check for Chrome user-agent string and clear the browser adapter mapping so that the control will be rendered irrespective of the client browser.

if (Request.UserAgent.IndexOf("Chrome") > 0)
{
    if (Request.Browser.Adapters.Count > 0)
    {
        Request.Browser.Adapters.Clear();
        Response.Redirect(Page.Request.Url.AbsoluteUri);
    }
}

The ControlAdapter provides a mapping between an ASP.NET Web Control and the adapter used to render the control in client browser.

If you are interested to dig deeper, then have a look at here and here.

Best way to use this code is to create a Base class inherited from System.Web.UI.Page and include this code in appropriate page event. Now, you can inherit this base class is those pages that require this piece of code.

Note: After clearing the Adapter for Chrome, I haven’t experienced any issues with other web controls so far. In case, if you are facing any issue, please feel free to share it.

Thanks

 

Categories: ASP.NET | Controls

Back, Back, Back

by abhilashca 4. March 2012 19:03

 

Hoooo!!! How frustrating it was. I’s on to tight work schedule. Didn’t got any free time to be with my pet projects nor with my blog Sad smile. It’s really frustrating and suffocating, if you know what I mean!

Now, I’m pretty free from my tight schedule and will get enough time to blog as well (finger’s crossed). Got a lot of things to update and lot of exciting things to share!

Keep watching! I’ so excited and thrilled. Because, I can enjoy the free-DOM. Smile

Thanks!

 

Tags:
Categories: General

End of an Era!

by abhilashca 6. October 2011 20:09


steve

Finally, An Era has come to an End. The world’s most successfully and inspired legend has passed away! Sad smile

 

Categories: Legends | Apple