By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,920 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,920 IT Pros & Developers. It's quick & easy.

ASP.Net with code behind c#. I have a buttons click event working in the wrong way

P: 1
The big problem that I am having is that I have a asp.net support manager website that I am building. One of my pages has a couple of buttons on it. The first button is and "add" or can be changed to an "update" button. When ever this button is clicked the page post back to itself and goes back through the ddl_TextChange event. I am trying to get this to stop happening because in part of my Text change event it clears all of my text boxes to reload from the database what is in the ddl box. If I am doing a update or an add to the database I don't want it to clear the text boxes out because I need the information from them to put into the database. I have tried to do a simple if test that if the btn_add.text == "Update" || btn_add.text == "Add" but the text on the button always says add unless the edit button was clicked then it changes the text to update. If you need more clarification on this I can try but I really don't want to post code on here because it has a lot of code in it. I was trying to find some information on doing a if test to see if the buttons click event did trigger this event but I haven't found any examples of someone doing this. Any ideas would be greatly appreciated or a point in the directions.
Oct 3 '07 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
The big problem that I am having is that I have a asp.net support manager website that I am building. One of my pages has a couple of buttons on it. The first button is and "add" or can be changed to an "update" button. When ever this button is clicked the page post back to itself and goes back through the ddl_TextChange event.
This should not happen unless the DDL_TextChange event is raised.

I was trying to find some information on doing a if test to see if the buttons click event did trigger this event but I haven't found any examples of someone doing this. Any ideas would be greatly appreciated or a point in the directions.
If you want to test this then you should put Break Points inside the method that handles the event....are you using Visual Studio? What version?

Are you sure that your text boxes aren't being cleared because of the PostBack? Is your ViewState saving their values are not?

-Frinny
Oct 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.