Reputation: 1
Thanks for your reply. When I click on 'click it first' link, the browser URL change. Where as I click on the second link it also update the URL in browser, but if I click on the "update button" which I have put in update panel, it post back some server function.
After that if I click on any of the link button the update URL functionality does not work.
Do u have any idea to reinitialize jQuery code after the update panel function?
I know that when we use jQuery with update panel, then we have to reinitialize it on every page load, but I am not able to find the correct jQuery function of that jQuery plugin to call on asp.net page load event.
Here is the link of that jQuery plugin
//Page Updating.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpdatingUrl.aspx.cs" Inherits="UpdateUrl.UpdatingUrl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-1.6.min.js" type="text/javascript"></script>
<script src="jquery.address-1.4.min.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<table class="style1">
<tr>
<td>
<a href="#" rel="address:/section/?id=1&name=Ravindra nofollow">Click it first</a>
</td>
<td>
<asp:Button runat="server" ID="UpdateButton1" OnClick="UpdateButton_Click" Text="Update" />
<asp:Label runat="server" ID="DateTimeLabel1" />
</td>
</tr>
<tr>
<td>
<a href="#" rel="address:/section/?id=2&name=Chauhan nofollow">Click it after Update
Button click</a>
</td>
<td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
//UpdatingUrl.aspx.cs Page
protected void UpdateButton_Click(object sender, EventArgs e)
{
DateTimeLabel1.Text = DateTime.Now.ToString();
}
Upvotes: 0
Views: 732
Reputation: 7355
You need _endRequest, _beginRequest Handlers. In code behind add this.
public object endRequestHandle { get; set; }
public object beginRequestHandle { get; set; }
In your aspx page, add this:
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandle);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandle);
function beginRequestHandle(sender, Args) {
//call any function if you want before Ajax update/request begins
}
function endRequestHandle(sender, Args) {
$.getScript("jquery.address-1.4.min.js", function(data, textStatus, jqxhr){});
}
Now, it will work, the script will be reloaded and executed. More on $.getScript() here
Upvotes: 1