welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, March 7, 2012

Solution for menu control problem in chrome browser

Recently I had faced problem menu control…Especially in chrome browser the menu control was not displaying properly...then I searched found some code would be useful to resolve my problem..
Here I share the code for those people for resolve this problem….
The below code is working perfectly for me..If you face the same problem try the below code.
Below code solve mostly solve your issues..
if Request.UserAgent.Contains("AppleWebKit") Then
    End If

Some other code I found when I searched….
protected void Page_PreInit(object sender, EventArgs e)
             // This is necessary because Safari and Chrome browsers don't display the Menu control correctly.
             if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
                 Page.ClientTarget = "uplevel";
protected override void AddedControl(Control control, int index)
            // This is necessary because Safari and Chrome browsers don't display the Menu control correctly.
            // Add this to the code in your master page.
            if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
                this.Page.ClientTarget = "uplevel";
                        base.AddedControl(control, index);
Add this below code in web.config file to solve the problems…..
<case match="Chrome/(?'version'(?'major'\d+)(?'minor'\.\d+)\.\d+.\d+)\sSafari/\d+\.\d+">browser=Chrome version=${version} majorversion=${major} minorversion=${minor}</case>
In this method you need to create App_Browser folder in solution explorer.. Follow the below steps.
 Right click Solution explore application name and in ASP.Net folder choose App_Browser
 App_Browsers folder and then, for this, Add New Item...
Select "Browser File" and name it Chrome.browsers.
Comment out the default stuff and insert this from the link above…
    <browser refID="safari1plus">
        <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />

I hop this code will be useful to all.please post your comment with the code wok for you ..It may ueful to someone…Happy coding…….


Post a Comment