(Forum Q & A)

xiaoxiao2021-03-05  25

Sometimes I want to trigger the server-side CLICK event to trigger the server-side control server. We write __dopostback ('id', '') but why is sometimes it works? Because the __dopostback () function does not generate on the page (if there is no LinkButton and other controls, the ASP.NET engine does not produce this JS) solution is as follows: such as front desk

<

ASP: Button

id

= "Button1"

Runat

= "Server"

TEXT

= "Button"

>

ASP: Button

>

(1)

<

a

HREF

= "#"

Onclick

= "Document.getElementByid ('Button1'). Click ()"

>

Trigger server-side button event

a

>

(2) Generate __dopostback () front desk with GETPOSTBACKEVENTRECERENCE

<

a

HREF

= "#"

Onclick

= "<% = Posback ()%>"

>

Trigger server-side button event

a

>

Backstage

protected

String

Postback ()

{Return this.page.getpostbackeventreference (this.button1, "haha");}

By __Eventargument = "Ha" can determine whether the POSTBACK of that link puts the button event of Button1:

IF

(REQUEST [

"

__Eventargument

"

]

==

"

Haha

"

)

{Response.write ("This is a link");}

Else

{Response.write ("This is not a link");

转载请注明原文地址:https://www.9cbs.com/read-34820.html

New Post(0)