Click here to Skip to main content
15,916,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have used model popup extender ...
and i used panel for window.
now i need to fire the text changed event when i hide the popup window.
but onclick event is working when i use this code ....


document.forms["aspnetForm"].elements["ctl00_ContentPlaceHolder1_btnClick"].click()


i need text changed event....
Posted

Here is the sample code with proper comments:

C#
// to register the ASP.NET server control
Page.GetPostBackEventReference(txtBox1);

//event to fire the TextChanged event of txtBox1
__doPostBack("txtBox1", "TextChanged");

// JavaScript function to handle the situation when the user just wanted to type
function DoPostBack()
{
   __doPostBack("txtBox1", "TextChanged");
}

//function on the OnChange event
if(!IsPostback)
{
    /...Implementation.../ 
    txtBox1.Attributes.Add("OnChange", "javascript:return DoPostBack()")
}
 
Share this answer
 
The question is not 100% clear, so I want to give you one general idea, and you can start from their.

You cannot fire any event from outside the class where event is declared. In other words, if you did not declare some event object in your class, you have no way to fire it directly. You cannot do it even in a derived class. It has nothing to do with access to the types and their members, access modifiers or anything at all; this is totally impossible. This is done for a purpose; one of the important limitations of the events compared to "regular" delegate instances, a fool-proof feature.

That said, you never really need it. You can only fire event indirectly. For example, if your event is TextChanged, you only can fire this event indirectly, by actually changing the text.

So, what to do in your case? First of all, you should understand that firing certain event is never your ultimate goal. You just need to call the same method on some other event. Nothing prevent you from doing that. In other words, don't write some code of the handler in the body of the handler of the event itself. Actually, never do. Write some single method which you can call from more then one place. Your handler of the event TextChanged should have only one call of this method in its body. And call the same method from any other place you need. Simple, isn't it?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900