which is referencing this update panel that contains a file upload. I am trying to prevent the page from giong back to the top after the user uploads an attachment.
You can see from my Javascript that I put in some alerts. It seems that my add_beginRequest and add_endRequest are never firing. Can anyone tell me why that is? Thanks for the
help in advance. This is .NET 3.5.
Thank you anyone who took the time to read this. It seems in fiddling around with the master page I had deleted the form tag. The add_BeginRequest and add_EndRequest are now firing. Not working right, but I can figure things out from here.
Marked as answer by BU XI - MSFT on Jun 18, 2012 03:16 AM
Melon Head
0 Points
11 Posts
add_beginRequest not working with ToolScriptManager?
Jun 12, 2012 05:30 PM|LINK
HI,
I have the following on an aspx page:
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
alert(xPos);
xPos = $get('<%= pnlAttachment.ClientID %>').scrollLeft;
yPos = $get('<%= pnlAttachment.ClientID %>').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('<%= pnlAttachment.ClientID %>').scrollLeft = xPos;
$get('<%= pnlAttachment.ClientID %>').scrollTop = yPos;
alert(yPos);
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
which is referencing this update panel that contains a file upload. I am trying to prevent the page from giong back to the top after the user uploads an attachment.
<asp:UpdatePanel ID="upnlAttachment" runat="server">
<ContentTemplate>
<cc1:CollapsiblePanelExtender runat="server" ID="cpeAttachment" TargetControlID="pnlAttachment"
ImageControlID="imgAttach" CollapseControlID="divAttach" ExpandControlID="divAttach"
ExpandedImage="~/Img/icon_minus.gif" CollapsedImage="~/Img/icon_plus.gif" SuppressPostBack="true"
CollapsedText="<br />Click on the plus icon to expand this section." ExpandedText=" "
TextLabelID="lblAttach" />
<div class="section-wrapper" id="divAttachment" runat="server">
<div id="divAttach" class="section-title">
<asp:Image ID="imgAttach" runat="server" ImageUrl="~/Img/icon_minus.gif" ImageAlign="AbsMiddle" /> Attachments
</div>
<asp:Label runat="server" ID="lblAttach" Text="."></asp:Label>
<asp:Panel runat="server" ID="pnlAttachment">
<asp:Table ID="Table8" runat="server" BorderWidth="0" CellPadding="5" CellSpacing="0"
Width="100%">
<asp:TableRow runat="server" ID="trAttachFile">
<asp:TableCell CssClass="label">
Attach a File:
<br />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="middle">
<input type="text" id="txtFakeFileUpload" class="file_input_textbox readonly" readonly="readonly" />
</td>
<td align="right" valign="bottom">
<div class="file_input_div">
<input type="button" value="Browse..." class="file_input_button" />
<asp:FileUpload ID="txtFileUpload" runat="server" CssClass="file_input_hidden" onchange="javascript: document.getElementById('txtFakeFileUpload').value = this.value;" />
</div>
</td>
<td align="right" valign="bottom">
<asp:Button ID="btnAttach" runat="server" Text="Attach" OnClick="btnAttach_Click" CausesValidation="false" />
</td>
</tr>
</table>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:UpdatePanel ID="upnlAttachments" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvAttachments" runat="server" AutoGenerateColumns="False" DataKeyNames="ATTACHMENT_ID"
EmptyDataText="No attachments have been submitted. Click on 'Browse...' then Attach button located to the right to upload a file to this record."
OnRowDataBound="gvAttachments_RowDataBound" OnRowDeleting="gvAttachments_RowDeleting"
OnRowCreated="gvAttachments_RowCreated" OnRowCommand="gvAttachments_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Current Attachments" SortExpression="FILENAME">
<ItemTemplate>
<asp:HyperLink ID="hlFileName" runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ADD_DATE" DataFormatString="{0:dd-MMM-yyyy}" HeaderText="Uploaded On"
HtmlEncode="False" SortExpression="ADD_DATE">
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="false" />
</asp:BoundField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:ImageButton ID="btnDelete" ImageUrl="~/Img/icon_delete.gif" runat="server" OnClientClick="return confirm('Are you sure you want to delete this attachment?');"
CommandName="Delete" />
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
This aspx page has a master page which is using the toolkitscriptmanager:
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
You can see from my Javascript that I put in some alerts. It seems that my add_beginRequest and add_endRequest are never firing. Can anyone tell me why that is? Thanks for the help in advance. This is .NET 3.5.
Melon Head
0 Points
11 Posts
Re: add_beginRequest not working with ToolScriptManager?
Jun 12, 2012 06:46 PM|LINK
Hi,
Thank you anyone who took the time to read this. It seems in fiddling around with the master page I had deleted the form tag. The add_BeginRequest and add_EndRequest are now firing. Not working right, but I can figure things out from here.