How to write a script on the client to trigger a server-side event processing process, such as online.

Source: Internet
Author: User

In simple terms, you can use JavaScript, but the method I suggest is different from that on the upstairs. I suggest directly calling the "server"
Client script function corresponding to the client event. For pages automatically output by Asp.net, there will be
Function _ dopostback (eventtarget, eventargument), you should use this function directly
PostBack (for example, _ dopostback ('button1', ''). Then the server can directly identify this PostBack as a pair
Event.

To be more complex, you can encapsulate this JavaScript code into your own server components. It is different from directly passing an event to the target control.
You need to define an event for your server control, and define in the page logic when your server control triggers this event,
Events that automatically trigger the target control. For example, You encapsulate a mywebcontrol and modify the client script
_ Dopostback ('mywebcontrol1 ', ''). Then, your mywebcontrol needs to write and capture this PostBack and generate the corresponding
Event code.

Place a button on the page, trigger the button with a script, and add the process to be processed in the Event Response Process of the button;
Document. Forms (0). Button. Click ();

Textboxname. Attributes. Add ("onmouseover", "This. Focus ()");
Textboxname. Attributes. Add ("onfocus", "This. Select ()");
. CS
Textbox3.attributes. Add ("onblur", "javascript: Check ();");

. Html
Function check ()
{
S = Document. All ("textbox3"). value;
S = parseint (s );
Document. All ("textbox3"). value = s;
}

 

<Script language = "JavaScript">

Function check ()
{
VaR;
S = Document. All ("textbox3"). value;
// S = parseint (S, 2 );
If (S. indexof (".") = "-1 ")
S = S + ". 00"
Else
{A = S. Split (".");
If (A [1]. Length = 1)
S = A [0] + "." + A [1] + "0 ";
}

Document. All ("textbox3"). value = s;
}

</SCRIPT>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.