ASPX中的事件处理 [英] Event Handling in ASPX

查看:56
本文介绍了ASPX中的事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有事件处理程序,我想调用该事件处理程序.但是对我来说这是不可能的.
贝娄是我的ASCX文件中的代码...

Hi,
i have event handler i want to invoke that one.but not possible to me.
Bellow is my Code in my ASCX File......

public delegate void PersonHandler(object sender,EventArgs e);
public event PersonHandler CountrySelectedIndexChange;
public event PersonHandler StateSelectedIndexChange;
public event PersonHandler btnUploadClick;
public event PersonHandler btnSubmitClick;

protected virtual void rcbCountryName_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (this.CountrySelectedIndexChange != null)
        {
            this.CountrySelectedIndexChange(sender, e);
        }
    }
    protected void rcbStateName_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (this.StateSelectedIndexChange != null)
        {
            this.StateSelectedIndexChange(this,e);
        }
    }


********

当我执行上面的代码时,我从CountrySelectedIndexChange获取空值,并且如果Loop ......,它没有进入. 所以请任何人帮我.


谢谢


********

when i execute the above code i am getting null value from CountrySelectedIndexChange and it did not enter into if Loop......
So please any one help me..


Thanks

推荐答案

我的猜测是(您的代码不完整)您在此处可能会干扰页面生命周期.将页面呈现给浏览器时,所有内容都会被破坏.这将包括您在页面首次显示给用户时进行的所有事件订阅.

根据浏览器的响应重新创建页面后,您需要确保在引发click事件之前重新预订了该事件.这是因为在回发后会创建页面的新实例,并在其中填充响应中的信息.
My guess is (your code is incomplete) that you are falling foul of the page life cycle here. Everything is destroyed when the page is rendered to the browser. This will include any event subscriptions you make when the page is first displayed to the user.

When the page is re-created following a response from the browser you need to make sure the events are re-subscribed to before the click event is raised. This is because on post-back a new instance of the page is created and filled with information from the response, amongst other things.


然后告诉我如何编写代码.
请帮助我
then tell me how to write code.
please help me


这篇关于ASPX中的事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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