在数据列表中的ModelPopup的Acees TaxtBox值 [英] Acees TaxtBox value of a ModelPopup which is within a Datalist

查看:65
本文介绍了在数据列表中的ModelPopup的Acees TaxtBox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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

推荐答案

find('panel_Popup').hide();//1st问题:无法找到Javascript控制面板_Popup
find('panel_Popup').hide();//1st Problem :Javascript unable to find the control panel_Popup


get(' DummyButton').click(); // 重定向到数据列表外部的dummy-Asp:Button的点击事件 } </script>
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


您好,

只需添加以下代码
Hi,

Just add following 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值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆