Asp.net interacts with the frontend and backend using js scripts

Source: Internet
Author: User

Function CallServerIns ()
{
GetXmlHttp ();
Var rbltable = document. getElementById ("Vote1_RadioButtonList1 ");
Var rbs = rbltable. getElementsByTagName ("INPUT ");
Var selid = "";
For (var I = 0; I <rbs. length; I ++)
{
If (rbs [I]. checked)
{
Selid = rbs [I]. value;
}
}
If (selid = "")
{
Alert ("select the ticket you want to vote ");
Return false;
}
Else
{
Var url = "VoteShow. aspx? Type = "+ escape (" add ") +" & id = "+ escape (selid );
// Var url = "WebForm1.aspx? Username = "+ escape (user) +" & sex = "+ escape (sexinfo) +" & age = "+ escape (age) + "& tel =" + escape (tel) + "& addr =" + escape (addr );
Xmlhttp. open ("post", url, true );
Xmlhttp. onreadystatechange = CallBackIns;
Xmlhttp. send ();
Return false;
}
}
Function CallBackIns ()
{
Var strInfo = "";
Var divid = document. getElementById ("InsInfo ");

If (xmlhttp. readyState = 1)
{
// Alert ("voting ...");
// StrInfo = "voting ...";
Divid. style. visibility = "visible ";
Divid. innerHTML = strInfo;
}
If (xmlhttp. readyState = 4)
{
StrInfo = xmlhttp. responseText;
/* Divid. style. visibility = "hidden ";
Var di = document. getElementById ("asd1 ");
Var dii = document. getElementById ("asd2 ");
Var diii = document. getElementById ("asd3 ");
Di. style. visibility = "visible ";
Dii. style. visibility = "visible ";
Diii. style. visibility = "visible ";
Diii. innerHTML = strInfo ;*/
Alert (strInfo );
}
}

//////////////////////////////////////// //// // The above is the js script //////// //////////////////////////////////////// //////////////////////////////////////// ////////

<Input onclick = "return showvote ();" type = "image" src = "images/a_chaka.jpg">

//////////////////////////////////////// /// // The above is the aspx page //////// //////////////////////////////////////// //////////////////////////////////////// ////////

Private void Vote (int id)
{
If (int) Session ["Vote"]! = 1)
{
Dal. UpdateTotle (id );
Session ["Vote"] = 1;
Response. Write ("Vote successful !! ");
Response. End ();

}
Else
{
Response. Write ("Please do not vote again! ");
Response. End ();
}

Related Article

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.