JavaScript various directional carry parameter transfer value problem. (window.location.href) __java

Source: Internet
Author: User

with variable

String id = request.querystring["id"]. ToString ();

Response.Write ("<script>alert" (' success '); Window.location.href (' reply.aspx?word_id= ' +id+ "');</script>");

int id=1;

String ip = Request.UserHostAddress.ToString ();

Response.Write ("<script>window.location.href" ("reply.aspx?word_id=" +id+ "&ip=" +ip+ "");</script> " );

The string and the value are carried the same.

Note:

1. Front Desk with parameters

<a href= "default.aspx?id=<% #Eval (" word_id ")%>" > Delete </a>

2. Background with parameters

Response.Redirect ("default.aspx?id=" +id);

Response.Redirect ("reply.aspx?id=" + ID + "&username=" + IP); ( multiple parameters to carry )

Question 1 How to access C # functions in JavaScript

Method One: 1, first establishes a button, in the backstage will call or the processing content writes in the Button_Click;
2, in the foreground to write a JS function, content for document.getElementById ("BTN1"). Click ();
3, in the foreground or backstage call JS function, fire click event, equal access to the background C # function;
Method Two: 1, function declared as public or protected
public string SS ()
{
Return ("a");
}
2, in the HTML used to call

There are several ways to do not enumerate, the younger brother often use is the above two kinds.

Question 2. How do I access C # variables in JavaScript?

Method One: 1, through the page hidden domain access
Method Two: 1, such as the background definition of public STRING N; foreground JS reference to the variable in the format of "or + +"
Method Three: 1, background registration script
" "
TMP is a background variable, and then you can directly access the temp to get the value in JS.

Question 3. How do I access the existing variables of JavaScript in C #?

Method One: 1, the foreground uses the static text control to hide the domain, writes the JS variable value to it;

2, the backstage uses request["the ID" to obtain the value;

Method Two: Cookie or session

Question 4. How do I access JavaScript functions in C #?

Method One: Page.registerstartupscript ("fuc", "");

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.