从用户控件访问父页面方法不会刷新 [英] Accessing Parent Page Method from User Control doesnot refresh

查看:121
本文介绍了从用户控件访问父页面方法不会刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

内部用户控制

Inside User Control

((parentPage)Parent.Page).callChildMethod();




如上所述,我调用了一个将父控件Label分配给新值的方法,我调试了代码,它向我显示了正确更改值的方法,即方法调用结束后,它再次进入用户控件并离开用户控件,但是如果页面没有显示更改的值,除非我们单击父页面以再次加载.


包含用户控件的父页面内的方法



公共无效的callChildMethod()
{
Label1.text ="value";
}




As above i called a method which assigns parent control Label to new values, i debug the code and it showed me the value is changed correctly which is to be, when the method call gets over it comes inside the user control again and leaves the User control but when the page doesnot showing the changed values unless we give click on the parent page to load again.


Method inside Parent Page which Holds User Control



public void callChildMethod()
{
Label1.text="value";
}

推荐答案

您的页面中是否有任何AJAX控件(例如UpdatePanel)用于刷新数据?

此外,通知父页面标签更改的更好方法是使用事件.
Are you any AJAX controls (like UpdatePanel) in your page for refreshing the data?

Also, a better way to notify the parent page about the label change will be using events.


这篇关于从用户控件访问父页面方法不会刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆