js獲取.aspx頁面里面的服務(wù)器控件和.ascx中的服務(wù)器控件值
更新時(shí)間:2009年02月17日 17:18:04 作者:
用js獲取.ascx控件中服務(wù)器控件值時(shí)首先要得到服務(wù)器控件的ClientID再加上.ascx頁面里面的服務(wù)器空間ID并用"_"連接
A.aspx頁面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="A.aspx.cs" Inherits="OrderManage_A" %>
<%@ Register Src="../UserControl/CtrlCalendar.ascx" TagName="CtrlCalendar" TagPrefix="uc1" %>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script language="javascript" type="text/javascript">
function GetValue()
{
var txpro=document.getElementById('<%=txtProvider_rename.ClientID %>');
//用js獲取服務(wù)器控件的值時(shí)首先要得到服務(wù)器控件的ClientID
var txdat=document.getElementById('<%=txtCheckIn.ClientID %>'+"_txtDateVal");
//用js獲取.ascx控件中服務(wù)器控件值時(shí)首先要得到服務(wù)器控件的ClientID再加上.ascx頁面里面的服務(wù)器空間ID并用"_"連接
txpro.value=txdat.value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<tr>
<td align="right" bgcolor="#dee5fa">入住日期</td>
<td align="left" bgcolor="#dee5fa"><uc1:CtrlCalendar ID="txtCheckIn" runat="server" /></td>
</tr>
<tr>
<td align="right" bgcolor="#dee5fa" onclick="GetValue()"><asp:TextBox ID="txtProvider_rename" runat="server" Width="312px"></asp:TextBox></td>
</tr>
</div>
</form>
</body>
</html>
CtrlCalendar.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CtrlCalendar.ascx.cs" Inherits="CtrlCalendar" %>
<table id="Table1" style="HEIGHT: 24px" cellspacing="0" cellpadding="0" width="100" border="0">
<tr>
<td style="WIDTH: 81px"><font face="宋體">
<asp:textbox id="txtDateVal" Width="84px" runat="server" BorderStyle="Groove"></asp:textbox></font></td>
<td><div id="Div_imgCanlendar"><font face="宋體"><img id="imgCanlendar" style="CURSOR: hand" alt="" src="../images/calendar.gif" runat="server" /></font></div></td>
</tr>
</table>
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="A.aspx.cs" Inherits="OrderManage_A" %>
<%@ Register Src="../UserControl/CtrlCalendar.ascx" TagName="CtrlCalendar" TagPrefix="uc1" %>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script language="javascript" type="text/javascript">
function GetValue()
{
var txpro=document.getElementById('<%=txtProvider_rename.ClientID %>');
//用js獲取服務(wù)器控件的值時(shí)首先要得到服務(wù)器控件的ClientID
var txdat=document.getElementById('<%=txtCheckIn.ClientID %>'+"_txtDateVal");
//用js獲取.ascx控件中服務(wù)器控件值時(shí)首先要得到服務(wù)器控件的ClientID再加上.ascx頁面里面的服務(wù)器空間ID并用"_"連接
txpro.value=txdat.value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<tr>
<td align="right" bgcolor="#dee5fa">入住日期</td>
<td align="left" bgcolor="#dee5fa"><uc1:CtrlCalendar ID="txtCheckIn" runat="server" /></td>
</tr>
<tr>
<td align="right" bgcolor="#dee5fa" onclick="GetValue()"><asp:TextBox ID="txtProvider_rename" runat="server" Width="312px"></asp:TextBox></td>
</tr>
</div>
</form>
</body>
</html>
CtrlCalendar.ascx
復(fù)制代碼 代碼如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CtrlCalendar.ascx.cs" Inherits="CtrlCalendar" %>
<table id="Table1" style="HEIGHT: 24px" cellspacing="0" cellpadding="0" width="100" border="0">
<tr>
<td style="WIDTH: 81px"><font face="宋體">
<asp:textbox id="txtDateVal" Width="84px" runat="server" BorderStyle="Groove"></asp:textbox></font></td>
<td><div id="Div_imgCanlendar"><font face="宋體"><img id="imgCanlendar" style="CURSOR: hand" alt="" src="../images/calendar.gif" runat="server" /></font></div></td>
</tr>
</table>
您可能感興趣的文章:
- asp.net“服務(wù)器應(yīng)用程序不可用” 解決方法
- aspx 服務(wù)器架設(shè)問題解決
- Asp.net的服務(wù)器推技術(shù) (Server Push)
- Javascript 直接調(diào)用服務(wù)器C#代碼 ASP.NET Ajax實(shí)例
- jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標(biāo)簽后的value和text值
- asp中判斷服務(wù)器是否安裝了某種組件的函數(shù)
- IIS服務(wù)器中 ASP.NET State Service 開啟后 Session 仍容易丟失的問題終極解決辦法
- asp在服務(wù)器把 XML 轉(zhuǎn)換為 XHTML的實(shí)現(xiàn)代碼
- win2008 r2 服務(wù)器環(huán)境配置(FTP/ASP/ASP.Net/PHP)
- iis8.5顯示ASP的詳細(xì)錯(cuò)誤信息500 內(nèi)部服務(wù)器錯(cuò)誤解決方法
- 服務(wù)器安全狗導(dǎo)致ASP.NET網(wǎng)站運(yùn)行出錯(cuò)的一個(gè)案例
- 推薦4款傻瓜型的ASP服務(wù)器軟件(asp運(yùn)行環(huán)境一鍵搭建工具)
- asp將本地的文件上傳到服務(wù)器
- asp服務(wù)器如何搭建
相關(guān)文章
ASP.NET性能優(yōu)化之讓瀏覽器緩存動(dòng)態(tài)網(wǎng)頁的方法
上一篇《ASP.NET性能優(yōu)化之構(gòu)建自定義文件緩存》我們通過OutputCache,讓請求去訪問服務(wù)器asp.net的輸出緩存,我們擴(kuò)展了OutputCacheProvider,這相當(dāng)于是訪問服務(wù)器上的靜態(tài)資源。2011-09-09asp.net 數(shù)據(jù)綁定的實(shí)例代碼
這篇文章介紹了asp.net 數(shù)據(jù)綁定的實(shí)例代碼,有需要的朋友可以參考一下2013-07-07在asp.net中操作sql server數(shù)據(jù)庫的一些小技巧
在asp.net中操作sql server數(shù)據(jù)庫的一些小技巧...2006-09-09RadioButtonList綁定圖片及泛型Dictionary應(yīng)用
讀取站點(diǎn)某一目錄的圖片,需要掌握LINQ與泛型Dictionary<TKey,TValue>的使用,本文將介紹RadioButtonList綁定圖片的實(shí)現(xiàn),感興趣的朋友可以了解下,或許對你有所幫助2013-02-02asp.net后臺關(guān)閉當(dāng)前頁面并傳值的兩種方法
這篇文章介紹了asp.net后臺關(guān)閉當(dāng)前頁面并傳值的兩種方法,有需要的朋友可以參考一下2013-10-10asp.net使用DataGridTree實(shí)現(xiàn)下拉樹的方法
這篇文章主要介紹了asp.net使用DataGridTree實(shí)現(xiàn)下拉樹的方法,詳細(xì)的講述了DataGridTree實(shí)現(xiàn)下拉樹的原理與具體實(shí)現(xiàn)方法,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-11