本文介绍了如何动态地将内容值创建到另一个页面..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,

i我在tree.aspx.cs页面后面的代码中动态创建内容和按钮。

Hello Friends,
i am dynamically create contents and buttons into my code behind "tree.aspx.cs" page likethis.

sbmainTbl.AppendFormat("<tr><td><div class=\"a\">{0}<div class=\"details\"<p id=\"p\">{1}</p><ul><li>Parent-UnitId:{2}</li><li>Address :{3}</li><li>City: {4}</li><li>EmailId: {5}</li><li>PhoneNo: {6}</li><li>FaxNo: {7}</li><li><input type=\"button\" value=\"ADD\"  onclick=\"f2();\" /></li></ul></div></div></div></td></tr>",
            CellText(dtparent.Rows[0]["UnitName"].ToString()),
            CellText(dtparent.Rows[0]["UnitName"].ToString()),
            CellText(dtparent.Rows[0]["ParentUnitId"].ToString()),
            CellText(dtparent.Rows[0]["Address"].ToString()),
            CellText(dtparent.Rows[0]["City"].ToString()),
            CellText(dtparent.Rows[0]["EmailId"].ToString()),
            CellText(dtparent.Rows[0]["PhoneNo"].ToString()),
        CellText(dtparent.Rows[0]["FaxNo"].ToString()));



现在我在该页面中有另一个名为Add.aspx Page的页面我有文本框


Now i have another page called "Add.aspx Page" in that page i have textbox

<asp:TextBox ID="txtunitname" runat="server" CssClass="textbox"></asp:TextBox>



现在我只想点击动态创建b utton在tree.aspx页面上unitname(动态创建值)将传递Add.aspx页面,文本框应填写单位名称。



亲切的帮助我,谢谢。


now i just want on click on dynamically create button on "tree.aspx" page the "unitname(dynamically create value)" will pass "Add.aspx" page and textbox should fill with unitname.

kindly help me, Thanks.

推荐答案

string UnitName = "something";
                string dynamciButton = "<input type=\"button\" value=\"ADD\"  onclick=\"f2('{0}');\" /> ";
                dynamciButton = string.Format(dynamciButton, UnitName); // testing, ignore
                LiteralControl control = new LiteralControl(dynamciButton); // testing , ignore
                this.Controls.Add(control); // testing , ignore





javascript:





javascript:

<script type="text/javascript">
        var f2 = function (unitvalue) {
            window.location = 'Add.aspx?unitvalue=' + unitvalue;
        }
    </script>







添加。 aspx:






Add.aspx:

protected void Page_Load(object sender, EventArgs e)
       {
           if (!Page.IsPostBack)
           {
               txtunitvalue.Text = Request.QueryString["unitvalue"] + "";
           }
       }







note onclick = \f2('{0}'); \/> ; ,,,这条线就是诀窍。




note: onclick=\"f2('{0}');\" /> "; ,,, this lines is the trick.


这篇关于如何动态地将内容值创建到另一个页面..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 20:31