开发者

CommandEventArgs null value in OnCommand event handler for a Custom WebControl implementing IButtonControl

开发者 https://www.devze.com 2023-01-14 07:49 出处:网络
I am very sorry for the long title but I really didn\'t know how to be more self explaining than this.

I am very sorry for the long title but I really didn't know how to be more self explaining than this.

The problem I have is this: I designed and developed a WebControl which consists in a simple set of elements that, combined togheter in the simplest way, defines a custom button. This control is the one I would like to use in my web application instead of Button and LinkButton control (reasons mainly rely on graphic and visual functionalities). In order to let the webcontrol behave like a button, it also implements the IButtonControl interface so that all elements needed by the framework in order to handle events and similar stuff are well provided. Well, this button I called BoxButton works fine everytime it is used, instead for one thing.

Sorry for the long prelude, now we can go straight to the real problem: In a page I have a ListView and in the listview I have the InsertItemTemplate enabled. Well this insertitemtemplate works fine when the OnItemInsert is fired by pressing a button inside the template (a button, an ordinary button control). Well, I sure wanted to place my BoxButton in place of the ordinary one. When I do this I have a problem. The handler function is this:

protected void Insert_BoxButton_Command(object sender, CommandEventArgs e) {
    if (e.CommandName == "Insert") {
        // Do something     
    }
}

Typically, the e object is able to give information to the developer in order to locate all data to be inserted. These data are available when I use a normal button, but when using a BoxButton it is null! Well, you could tell me that, when I defined my BoxButton implementing the IButtonControl interfaces, I had to manage with both the two events in the interface (dealing woth button pressure: Click and Command) and manage with the pro开发者_如何学Pythonblem of providing CommandEventArgs. But how to do this? Is there a solution to my problem? How can I manage eventargs? I sense that probably this is a very low programming issue... maybe there is much to do. Thanks in advance for your help. Andry

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号