更新的UpdatePanel还原到以前的状态

问题描述

所以,我的问题是,在这种情况下,我想在单击每个按钮时更新中继器,但是我希望它们执行不同的功能,所以我将EventHandlers传递给我的Update函数。不幸的是,面板更新一次后,面板返回到之前的状态并且我的按钮的事件不会触发。在这种情况下,RepeaterMinorControl_Click确实会被调用,但是之后按钮的事件不会触发。每个按钮都执行AsyncPostback。

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="10G.aspx.cs" Inherits="OEDUY.Grades._10._10G" ClientIDMode="AutoID" %>



<!DOCTYPE html>



<html xmlns="[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)">

<head runat="server">

<title></title>

<link rel="stylesheet" href="../../FormsStyleSheets/StyleSheets/10G.css" />

</head>

<body>

<form id="form1" runat="server">

<div class="titleDiv">

<span></span>

</div>

<asp:ScriptManager runat="server" ID="scriptManager"></asp:ScriptManager>

<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="updatePFB">

<ContentTemplate>

<asp:Repeater runat="server" ID="buttonRepeater">

</asp:Repeater>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="buttonRepeater" />

</Triggers>

</asp:UpdatePanel>

</form>

</body>

</html>

这是C#代码:

string mainPath;

string currentMinorKey;

string currentLessonKey;

string currentSeasonKey;



protected void Page_Load(object sender,EventArgs e)

{

mainPath = Context.Request.MapPath("~");

string[] dirs = Core.Core.DirectoryController.GetSubDirectories($"{mainPath}Grades\\10");

var req = Request.Form;

FillButtonRepeater(dirs,new Action<object,EventArgs>(RepeaterMinorControl_Click));

}



protected void FillButtonRepeater(string[] Values,Action<object,EventArgs> ButtonAction)

{

buttonRepeater.Controls.Clear();



foreach (string item in Values)

{

Button control = new Button() { Text = Core.Core.DirectoryNameController.GetValue(item),CssClass = "btns",ID = $"{item}btn",UseSubmitBehavior = false };

control.Click += ButtonAction.Invoke;

buttonRepeater.Controls.Add(control);

}

}



private void RepeaterMinorControl_Click(object sender,EventArgs e)

{

currentMinorKey = Core.Core.DirectoryNameController.GetKey((sender as Button).Text);

string[] dirs = Core.Core.DirectoryController.GetSubDirectories($"{mainPath}Grades\\10\\{currentMinorKey}");

FillButtonRepeater(dirs,EventArgs>(RepeaterLessonControl_Click));

}



private void RepeaterLessonControl_Click(object sender,EventArgs e)

{

currentLessonKey = (sender as Button).Text;

string[] dirs = Core.Core.DirectoryController.GetSubDirectories($"{mainPath}Grades\\10\\{currentMinorKey}\\{currentLessonKey}");

FillButtonRepeater(dirs,EventArgs>(RepeaterSeasonControl_Click));

}



private void RepeaterSeasonControl_Click(object sender,EventArgs e)

{

currentSeasonKey = Core.Core.DirectoryNameController.GetKey((sender as Button).Text);

string[] dirs = Core.Core.DirectoryController.GetSubDirectories($"{mainPath}Grades\\10\\{currentMinorKey}\\{currentLessonKey}\\Seasons\\{currentSeasonKey}");

FillButtonRepeater(dirs,EventArgs>(RepeaterControlDirectory_Click));

}



private void RepeaterControlDirectory_Click(object sender,EventArgs e)

{

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...