gpt4 book ai didi

c# - 更新面板内的中继器 - ItemComand 代码问题 - 在代码隐藏中使用 ScriptManager 调用 javascript 函数

转载 作者:行者123 更新时间:2023-11-30 18:37:53 25 4
gpt4 key购买 nike

<分区>

我在 aspx 区域的中继器如下所示:
此中继器位于母版页内 - 页面基于母版页和内容页

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:Image ID="imgArrowIconInsideRepeater" runat="server" ImageUrl="~/Images/Login/ArrowIcon.png"
/>
<asp:HiddenField ID="hfFilePath" runat="server" Value='<%# Eval("FilePath")%>' />
<asp:HiddenField ID="hfFileName" runat="server" Value='<%# Eval("FileName")%>' />
<asp:HiddenField ID="hfFileSize" runat="server" Value='<%# Eval("FileSize")%>' />
<asp:HiddenField ID="hfFileCreationDate" runat="server" Value='<%# Eval("FileCreationDate")%>' />
<asp:LinkButton ID="lbFile" runat="server" CommandName="lbFile_Click" CssClass="lbFileInRepeater"
><%# Eval("FileName")%></asp:LinkButton>
<br />
<asp:Label ID="lblFileCreationDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FileCreationDate", "{0:yyyy/MM/dd - tt h:m:s}") %>'
CssClass="lblFileCreationDateInRepeater" ></asp:Label>
|
<asp:Label ID="lblFileSize" runat="server" Text='<%# GetFileSize(Eval("FileSize"))%>'
CssClass="lblFileSizeInRepeater"></asp:Label>
<div class="EmptyDiv">
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

我的母版页中还有一个脚本管理器,如下所示:

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True">
</telerik:RadScriptManager>

我在后面的代码中的 C# 代码如下所示:

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//The Below Line Does Not Work - Always Is Null
//NewAddedFiles currentItem = (NewAddedFiles)e.Item.DataItem;

HiddenField hfFilePath = (HiddenField)e.Item.FindControl("hfFilePath");
HiddenField hfFileName = (HiddenField)e.Item.FindControl("hfFileName");
HiddenField hfFileSize = (HiddenField)e.Item.FindControl("hfFileSize");
HiddenField hfFileCreationDate = (HiddenField)e.Item.FindControl("hfFileCreationDate");

switch (e.CommandName)
{
case "lbFile_Click":
{
if (Session["User_ID"] != null)
{
DataSet dsDownload = DataLayer.Download.Size_By_UserID_Today(int.Parse(HttpContext.Current.Session["User_ID"].ToString()), DateTime.Now);
if (dsDownload.Tables["Download"].Rows.Count > 0)
{
DataRow drDownload = dsDownload.Tables["Download"].Rows[0];

int SumOfFileSize4Today = int.Parse(drDownload["FileSizSum"].ToString());

if (SumOfFileSize4Today + int.Parse(hfFileSize.Value) <= 1073741824)//1 GB = 1024*1024*1024 bytes = 1073741824 bytes
//if (SumOfFileSize4Today + int.Parse(hfFileSize.Value) <= 100000)
{
DataLayer.Download.InsertRow(
int.Parse(HttpContext.Current.Session["User_ID"].ToString()),
DateTime.Now,
hfFilePath.Value,
hfFileName.Value,
hfFileSize.Value,
DateTime.Parse(hfFileCreationDate.Value)
);
Response.Redirect("~/HandlerForRepeater.ashx?path=" + hfFilePath.Value);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "YouCanNotDownloadAnyMore_SizeOverload", "YouCanNotDownloadAnyMore_SizeOverload();", true);
}
}
else
{
if (int.Parse(hfFileSize.Value) <= 1073741824)
//if (int.Parse(hfFileSize.Value) <= 100000)
{
DataLayer.Download.InsertRow(
int.Parse(HttpContext.Current.Session["User_ID"].ToString()),
DateTime.Now,
hfFilePath.Value,
hfFileName.Value,
hfFileSize.Value,
DateTime.Parse(hfFileCreationDate.Value)
);
Response.Redirect("~/HandlerForRepeater.ashx?path=" + hfFilePath.Value);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "YouCanNotDownloadAnyMore_SizeOverload", "YouCanNotDownloadAnyMore_SizeOverload();", true);
}
}
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "plzLoginFirst_ForDownload", "plzLoginFirst_ForDownload();", true);
}
break;
}

default:
{
break;
}
}
}
}

我的问题与这些行有关:从 ScriptManager.RegisterStartupScript 开始
为什么这些行在更新面板内不起作用? - 没有更新面板,一切都很好。

提前致谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com