青春几米光

点击这里给我发消息

导航

c# webform js文件获取客户端控件,后台cs获取前台客户端控件的值

aspx文件: Hidden2为客户端控件 Html代码 1.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 2. 3. 4. 5. 6. 7. 8. 9. 10. 无标题页 11. 12. 13.
14.
15. 16. 17. 18.
19.
20. 21. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 无标题页
给Hidden2控件赋值 js文件 Js代码 1.// JScript 文件 2. 3. function a() 4. { 5. document.getElementById("Hidden2").value="456"; 6. } // JScript 文件 function a() { document.getElementById("Hidden2").value="456"; } 取出Hidden2控件的值 cs文件 C#代码 1.using System; 2.using System.Data; 3.using System.Configuration; 4.using System.Web; 5.using System.Web.Security; 6.using System.Web.UI; 7.using System.Web.UI.WebControls; 8.using System.Web.UI.WebControls.WebParts; 9.using System.Web.UI.HtmlControls; 10. 11.public partial class _Default : System.Web.UI.Page 12.{ 13. protected void Page_Load(object sender, EventArgs e) 14. { 15. 16. } 17. protected void Button1_Click(object sender, EventArgs e) 18. { 19. Response.Write(Request.Form["Hidden_name"].ToString()); 20. } 21.} using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Response.Write(Request.Form["Hidden_name"].ToString()); } }

posted on 2012-03-05 16:44  青春几米光  阅读(524)  评论(0编辑  收藏  举报