views:

81

answers:

1

Hello everyone,

I got a strange problem, which I could not find a solution. In order to clarify my problem, I did a simply test page that has the same problem.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test1.aspx.cs" Inherits="RadicaLogic.SilverSpine.Web.Surveillance.Reports.test1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmanager" runat="server" />
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <asp:Button ID="btn1" runat="server" Text="test1" />
            <%= DateTime.Now %>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Button ID="btn2" runat="server" Text="test2" />
        <script type="text/javascript" language="javascript">
        $(document).ready(pageInit);
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(pageInit);

        function pageInit() {
            window.location.hash = "#0";
        }
    </script>

    </form>
</body>
</html>

In this test page, I have two button. "test1" button is inside an updatepanel. "test2" button is outside. When I run this page, I can see the url, for example "http://localhost/test/test1.aspx#0". After I click the "test1" button, I can see the url changed to "http://localhost/test/test1.aspx#". The "0" is missed. And after that, everything is ok. If I test the "test2" button. Everything is ok too.

I also find this problem only happens in IE. FireFox works fine.

My question is how can I keep the right url when I click the "test1" button?

Thanks

A: 

I think that the endRequest is not called because the pageInit not have the right arguments.

Try this

<script type="text/javascript" language="javascript">
    $(document).ready(pageInit);

    function pageInit() {
        window.location.hash = "#0";
    }    

    var prm = Sys.WebForms.PageRequestManager.getInstance();        
    prm.add_endRequest(EndRequest);

    function EndRequest(sender, args) {
        window.location.hash = "#0";
    }
</script>
Aristos
thanks Aristos, I try your suggestion. Unfortunately, It does not work. The endRequest should be called in my code. Because I add a alert("reach here"); line in my pageInit function. It is popped up every postback. Thanks.Any more suggestions? guys