__doPostback - call code for events from JavaScript?

I want to call a method in my code behind JavaScript, I kind of know how to do it .. I have to __DoPostBackname the passing name of the control and parameters ..

But what if the event does not exist, i.e. NO CONTROL. Actually, what I'm trying to do is to trigger an event .. but the event does not exist, since no control is associated with it.

I could do this:

If IsPostBack Then
       If Request("__EVENTTARGET").Trim() = "CleanMe" Then
           CleanMe()
       End If
.....

But that means I have to do it manually. Can I not connect the event .... otherwise I will have a lot of different IFs (i.e. if this passed, then call, etc.).

Any ideas?

thanks

+3
source share
3 answers

__doPostBack(), . . , __doPostBack() , , Foo(), :

MyControl : IPostBackEventHandler
{
    void RaisePostBackEvent(string eventArgument)
    {
        Foo();
    }
}

__doPostBack() RaisePostBackEvent .

+2

, , , - asp javascript

+1

Source: https://habr.com/ru/post/1706463/


All Articles