简体   繁体   English

ASP.NET事件处理程序不更改UI

[英]ASP.NET Event Handlers Not Changing UI

I have an instance of a custom business class on a asp.net web forms page (.NET 4.0). 我在asp.net Web表单页面(.NET 4.0)上有一个自定义业务类的实例。 This class has custom events that get thrown. 此类具有抛出的自定义事件。 My web forms page establishes the event handlers for the events before calling the business class. 我的Web表单页面在调用业务类之前为事件建立了事件处理程序。 These event handlers do stuff to the page (set a label's text, change a mulitview, etc.). 这些事件处理程序会对页面进行填充(设置标签的文本,更改多视图等)。 My problem is that sometimes, the event handler fires (verified by debugging the code and running through it), but the changes to the UI (setting a label's text) does not show on the page 我的问题是,有时事件处理程序会触发(通过调试代码并运行它来验证),但是UI的更改(设置标签的文本)未显示在页面上

Here is an simplified example - 这是一个简化的示例-

private void MyMethod()
{
   var myClass = new MyClass();
   myClass.PromptForAdditionalData += OnPromptForMoreData;
   myClass.DoSomethingElse += OnDoSomethingElse;

   myClass.ExecuteMethod();
}

private void OnPromptForMoreData(object sender, EventArgs e)
{
   label3.Text = "Blah blah blah";
   multiView1.SetActiveView(view1);
}

Other options without AJAX, try to postback or redirect to current page. 其他没有AJAX的选项,请尝试回传或重定向到当前页面。

This is the link to redirect : https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx 这是重定向的链接: https : //msdn.microsoft.com/zh-cn/library/a8wa7sdt(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM