Solution for submitting and passing values of server-side controls

Source: Internet
Author: User

Why is it important to emphasize the server side? It is mainly because I am not very good at writing JavaScript, so I always like to put programs in CS files in the background. In fact, my idea is quite in line with the ASP. NET idea. The page display and background code are completely separated!

Assume that there is a page on which a textbox accepts user input. When the user clicks the submit button, the value entered by the user in the textbox is passed to the next page. The following two cases are described respectively:

(Assume that the target page is main. aspx and the value to be passed is stored in the string Str)

1. Click Submit and jump to the target page immediately from the current page. You can use the following code to achieve this:

Response. Redirect ("Main. aspx? STR = "+ textbox1.text );

2. Click Submit to open the target page in a new window and keep the current page. You can use the following code to achieve this:

Page. clientscript. registerstartupscript (page. GetType (), "", "window. Open (main. aspx? STR = "+ textbox1.text +" ') ", true );

 

To obtain the passed value on the target page, use the following code:

String STR = request. querystring ["str"]. tostring ();

 

Reminder: all the controls mentioned above refer to server-side controls. If you want to implement it using a client control, you must use the corresponding JavaScript code. For more information, see.

 

Note: This article is original works, reprint please indicate the source: http://www.cnblogs.com/luzx

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.