问题描述
我有一个ModelPopup&弹出面板中有一个Datalist-Itemtemplate.
弹出面板包含TextBox,OkButton和CancelButton.
我需要从Ok-Button上的上述TextBox中获取输入,请点击
到我的鳕鱼背后进行进一步处理.
-------------------------------------------------- ------------
I have a ModelPopup & Popup-panel wihtin a Datalist-Itemtemplate.
Popup-panel contains TextBox, OkButton and CancelButton.
I need to get the input from the above TextBox on Ok-Button click
to my cod-behind for further processing.
--------------------------------------------------------------
<script type ="text/javascript" >
function forOkbtn()
{
//$find('panel_Popup').hide();//1st Problem :Javascript unable to find the control panel_Popup
$get('DummyButton').click();//Redirect to click event of dummy-Asp:Button which outside of Datalist
}
</script>
-------------------------------------------------- ---------------
//后面的代码
-----------------------------------------------------------------
//Code behind
protected void DummyButton_Click(object sender, EventArgs e)
{
TextBox popupTxt = (TextBox)DataList1.FindControl("ModelTxt");//2nd Problem :Unable to find the TextBox: ModelTxt
String PopupTextBoxValue = popupTxt.Text;
}
-------------------------------------------------- -----------------
我知道这不是正确的方法.期待更直接的方法或在上面的代码中建议更正
-------------------------------------------------------------------
I know this is not a right way. Expecting a more straight forward way Or Suggest Correction in the above code
推荐答案
-------------------------------------------------- ---------------
//后面的代码
-----------------------------------------------------------------
//Code behind
protected void DummyButton_Click(object sender, EventArgs e)
{
TextBox popupTxt = (TextBox)DataList1.FindControl("ModelTxt");//2nd Problem :Unable to find the TextBox: ModelTxt
String PopupTextBoxValue = popupTxt.Text;
}
-------------------------------------------------- -----------------
我知道这不是正确的方法.期待更直接的方法或在上面的代码中建议更正
-------------------------------------------------------------------
I know this is not a right way. Expecting a more straight forward way Or Suggest Correction in the above code
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListItemType.AlternatingItem:
case ListItemType.Item:
Button btn = (Button)e.Item.FindControl("DummyButton");
TextBox txt = (TextBox)e.Item.FindControl("ModelTxt");
btn.Attributes.Add("onclick", "alert('" + txt.Text + "'); return false;");
break;
}
}
谢谢,
Imdadhusen
Thanks,
Imdadhusen
这篇关于在数据列表中的ModelPopup的Acees TaxtBox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!