Fixed server side event from jQuery - __EVENTARGUMENT Doesn't exist

I am trying to start submitting a form via jQuery and have a special fire on the server side.

Client Code:

$("input[name=__EVENTARGUMENT]").val("SomeArg");
form = $("body form");
form.submit(); 

Server Code:

protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            if (Request["__EVENTARGUMENT"] == "SomeArg")
            {
                //do some stuff
            }
        }
    }

The problem is that the hidden input "__EVENTARGUMENT" does not exist. I found that if I add an ASP.NET server management dropdown with autopostback = true, EVENTARGUMENT hidden input will be created. Is there a cleaner way to get ASP.net to create these hidden inputs and let me get their values ​​on the server side without adding controls that I really don't need on the page?

+3
source share
1 answer

asp.net HiddenField control

, , , as.net , , ClientID ,

+2

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


All Articles