分享

后台代码获取/设置前台控件值

 悟静 2012-11-11

在运用JQury+母版页时

发现JQuery 调用不了服务器控件 不能实现前段效果

所有使用前台控件

要使控件值得到交互

通过森戳-萎缩思想 ....方法如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="TNT.ETourBusinessPlatform.Web.bar.test" MasterPageFile="~/MasterPage.Master"%>
<asp:Content ID="Content1"  runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <script src="../js/jquery-min-lastest.js" type="text/javascript"></script>
   
   <style type="text/css">
    .l01
    {
     width:100px;
     height:20px;
     margin-top:10px;
     margin-left:10px;
     
    }
    </style>
   
    <script type="text/javascript">
        $(function() {
        $("#txt").click(function() {
                alert("asdf");
            })
        })
    </script>

    <div>
        <%= show_input_txt() %>
        <input id="Submit1" type="submit" value="submit" />
        <%=s %>
    </div>


</asp:Content>

------

后台

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TNT.ETourBusinessPlatform.Web.bar
{
    public partial class test : System.Web.UI.Page
    {
        public string input_txt_value;
        public string s;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            { s = Request.Form.Get("txt"); }
        }

        public string show_input_txt()
        {
            input_txt_value = "呵呵";
            return ("<input type=\"text\" name=\"txt\"  id=\"txt\" value=\""+input_txt_value+"\" />");
        }
    }
}
------很诡异。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多