码迷,mamicode.com
首页 > Web开发 > 详细

asp.net中updatepanel控件向外传值

时间:2014-12-11 15:57:36      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:updatepanel   asp.net   

bubuko.com,布布扣bubuko.com,布布扣

.aspx代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpdatePanel控件传值.aspx.cs" Inherits="UpdatePanel控件传值" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery-1.8.3.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p><%=DateTime.Now.ToString() %></p>
    您选择的日期为:
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <p><%=DateTime.Now.ToString() %></p>
        <asp:Calendar ID="Calendar1" runat="server" 
            onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

.aspx.cs代码如下:

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

public partial class UpdatePanel控件传值 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        string _cl = Calendar1.SelectedDate.ToLongDateString();
        string _script = "$('#TextBox1').val('"+_cl+"')";
        ScriptManager.RegisterStartupScript(this,this.GetType(),"",_script,true);
    }
}
借助JQuery实现数据在控件间传递。

效果如下:

bubuko.com,布布扣

asp.net中updatepanel控件向外传值

标签:updatepanel   asp.net   

原文地址:http://blog.csdn.net/yayun0516/article/details/41866229

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!