用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

asp.net 保存、修改没有 runat=server控件的控件值的一个解决方案

时间:2015-01-29  来源:互联网  作者:佚名

js:
复制代码 代码如下:
function Save()//保存不是服务端控件的值
{
var 1= document.getElementById('1Box').value;
var 2 = document.getElementById('2Box').value;
var TxtValue = 1 + "■" + 2;
document.getElementById('3).value = TxtValue;
return true;
}
window.onload=function show()
{
var TxtValue = document.getElementById('3).value;
if (TxtValue != "") {
EachValue = new Array();
EachValue = TxtValue.split('■');
document.getElementById('1Box').value = EachValue[0];
document.getElementById('2Box').value = EachValue[1];
}
return true;
}

html:
复制代码 代码如下:
<input type="text" id="1Box" class="txt-underline" style="width: 60px;text-align:left " maxlength="10"/>
<input type="text" id="2Box" class="txt-underline" style="width: 200px;text-align:left" maxlength="30"/>
<input type="hidden" id="3" name="Values" runat="server" />

CS:
复制代码 代码如下:
void LoadData()//页面加载
{
btnSave.Attributes.Add("onclick", "javascript:Save();");
string[] strTxtValues = new string[2];
strTxtValues[0] = dr["1"].ToString();
strTxtValues[1]=dr["2"].ToString();
string strValues = strTxtValues[0];
for (int i = 1; i < strTxtValues.Length; i++)
{
strValues += "■" + strTxtValues[i];
}
this.3.Value = strValues;

private void SaveOrUpdate()//保存、修改
{
string[] strTxtValues = this.3.Value.Split('■');
string 1= strTxtValues[0];
string 2= strTxtValues[1];

来顶一下
返回首页
返回首页
推荐资讯
jQuery 插件autocomplete自动完成应用(自动补全)(asp.net后台) jQuery 插件autocomplete自动完成应autocomplete官网 : http://bassistance.de/jquery-plugins
Win2008 server + IIS7 设置身份模拟(ASP.NET impersonation) Win2008 server + IIS7 设置身份模作者:eaglet转载请注明出处IIS7 与 IIS 6 相比有了很大的改
相关文章
栏目更新
栏目热门