Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a visual web part in which one button and a label inside an update panel. When I run the web part in IE and Firefox it works fine but it does not work in Safari.

My declarative part is:

<asp:UpdatePanel ID="pnlFirst" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnClick" runat="server" OnClick="btnClick_Click" Text="Click Here" />
        <asp:Label ID="lblMsg" runat="server"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

My code is:

int count = 0;
protected void Page_Load(object sender, EventArgs e)
{
    count = Convert.ToInt32(ViewState["count"]);
    CallJavascript();
}

private void CallJavascript()
{
    string script = @"Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit"+
                    @"if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )"+
                     @"{ Sys.Browser.agent = Sys.Browser.WebKit; Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);"+
                      @"Sys.Browser.name = 'WebKit';}";
    ScriptManager.RegisterClientScriptBlock(this,GetType(),"Script",script,true);
}

protected void btnClick_Click(object sender, EventArgs e)
{
    lblMsg.Text = "Refresh Value:" + count;
    ViewState["count"] = ++count;
}

I searched over internet for the issue and found this link to troubleshoot the problem. That's why I included CallJavascript() method. But it's not working in my case. I debugged the program and found that the when I click from Safari the button_click does not fire. The control just goes away from page load. What should I do?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.