4

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?

1 Answer 1

0

I have a similar problem.

I am testing one thing that might do the trick: Make all your update panels on updatemode=conditional.

This is not working so i will try the second solution in Ali SharePoint answer: UpdatePanel in sharepoint not working in Safari browser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.