开发者

Cancelling TextChanged events (ASP.NET)

开发者 https://www.devze.com 2023-02-06 22:33 出处:网络
I have a bit of an issue with something I\'m working on in ASP.NET/C#. I am using a GridView to display all \'items\' linked to an account, with 3 fields relating to the link, but also all files not l

I have a bit of an issue with something I'm working on in ASP.NET/C#. I am using a GridView to display all 'items' linked to an account, with 3 fields relating to the link, but also all files not linked to it. Next to all records is a checkbox so they can link/unlink the two, and modify the 3 fields relating to that link.

I am currently using the 'CheckedChanged' and 'TextChanged' events to update the entries, as opposed to looping through each row in the Grid, checking its current state and updating accordingly etc which would provide a lot of overhead.

Problem is,the events fire if the user clicks a 'Cancel' button. Is there a way to detect if this certain button has 开发者_如何学运维been Clicked, and stop the events from firing? Or do you guys have better ideas?


First of all, it sounds like your Cancel button's Clicked handler is assigned to your custom function somewhere. By default it shouldn't do anything.

However, you can use the Sender object to check the type of object that fired the event:

if (sender is Checkbox) {
    // Do something useful
}

I have not tested this code.

0

精彩评论

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