Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to fire OnTextChanged in Submit method?
Message
 
 
À
29/12/2008 16:48:25
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01370003
Message ID:
01370014
Vues:
24
>>>>I have a textbox that fires when user changes the entry. The OnTextChanged method calls database and validates that the entry exist in the database. However, the user may not change the default entry in this text box (the text box gets a default entry from a cookie) and simply click on Submit. I need to call this OnTextChanged method in the Submit method. The following is the top line of the method:
>>>>
>>>>
>>>>public void txtCostCenter_TextChanged(object sender, System.EventArgs e)
>>>>
>>>>
>>>>In order to call this method in the Submit I need to pass the parameters (that I don't even use). How can I pass some dummy parameters that would satisfy the compiler in terms of type of parameters?
>>>
txtCostCenter_TextChanged(new object(),new EventArgs());
>>
>>Thank you very much! It works. But let me ask you a follow up question (if you are not yet tired of me too much {g}). Do you think it is better to break my method txtCostCenter_TextChanged into 2 methods? That is, to have a separate method that only validates the entry. Then I can call just the Validate method from the Submit method. I am just thinking of the best practice of maintaining the code.
>
>You mean have the TextChanged event and the Submit both call a common method? In that case, yes, I think it would be better practice.....
>Regards,
>Viv

Yes, this is exactly what I meant. I guess with your help I now know how to call TextChanged method from the Submit but it would be "cleaner" to have a separate method to be called from the TextChanged and from Submit. Again, thank you for your help.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform