. NET background fetch JS assigned value to Hidden

Source: Internet
Author: User

 <script type= "Text/javascript" >//with "Select All" check box as parameter function Checkall () {var checkall = Document.getelement        Byid ("All");        var Checkitem = document.getelementsbytagname ("input"); for (var i = 0; i < checkitem.length; i++) {if (checkitem[i].type== "checkbox") {Checkitem[i].            checked = checkall.checked;            }}}//Gets the selected check box function Update () {var chkitems = document.getelementsbyname ("Item");                       var bookId = "";                    for (var i = 0; i < chkitems.length; i++) {if (chkitems[i].checked) {                BookId + = Chkitems[i].value + ",";                      }} bookId = Bookid.substr (0, bookid.length-1);                document.getElementById (' <%=hidBookId.ClientID%> '). Value = BookId;        Alert (document.getElementById (' <%=hidBookId.ClientID%> '). Value); }</script>

HTML code:

<input type= "checkbox" id= "All" onclick= "Checkall ()"/> Select all <input type= "checkbox" Name= "Item" value= "<%# Eval ("Id")%> "/>

  <input type= "hidden" id= "Hidbookid"  name= "Hidbookid" runat= "Server"/> The      selected books are categorized in: <asp:d Ropdownlist id= "ddlcategory" runat= "Server" ></asp:DropDownList>  <asp:button id= "Btncategory" runat = "Server" text= "Modify  " onclick= "Btncategory_click"  onclientclick= "Update ();"/>

 

Background code:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;using model;using bll;public partial class listbooksbycategory:system.web.ui.page{Prote CTED void Page_Load (object sender, EventArgs e) {if (!            IsPostBack) {categorybind ();                Booksbind (); }}///<summary>//Binding Data///</summary>//<param name= "PM" ></param> PR otected void Booksbind () {list<book> List = new Bookmanager ().        Getallbooks ();        This.gvBooks.DataSource = list;    This.gvBooks.DataBind (); }///<summary>//binding book type name///</summary> protected void Categorybind () {this.ddlcate Gory. DataSource = new Categorymanager ().        Getallcategory ();        This.ddlCategory.DataTextField = "Name";        This.ddlCategory.DataValueField = "Id";    This.ddlCategory.DataBind (); } protectedvoid Gvbooks_pageindexchanging (object sender, Gridviewpageeventargs e) {//Get index number This.gvBooks.PageIndex        = E.newpageindex;    Booksbind (); }///<summary>///Click Modify button Events///</summary>//<param name= "sender" ></param>/// Lt;param name= "E" ></param> protected void Btncategory_click (object sender, EventArgs e) {str       ing strbookid = this.hidBookId.Value;       string[] Array = strbookid.split (', '); for (int i = 0; i < array. Count ();           i++) {int categoryId = Convert.ToInt32 (This.ddlCategory.SelectedValue); New Bookmanager ().       Updatecategoryidbyid (Convert.ToInt32 (Array[i]), categoryId);    } booksbind (); }}

  

. NET background fetch JS assigned value to Hidden

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.