开发者

how to get HiddenField Value from ascx.cs page to aspx.cs page

my ascx code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Demo.ascx.cs" Inherits="Demo" %>
<asp:HiddenField ID="hidden1" runat="server" Value=""/>
<asp:Label ID="lbl1" runat="server" Text="Hiii"></asp:Label>

my ascx.cs code :

protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            lbl1.Text = "Mahendra Kamble开发者_JS百科";
            hidden1.Value = "123";
        }   



    }

my aspx code:

<%@ Register TagName="TopBar" TagPrefix="CRS" Src="~/Demo.ascx" %>
---
--
<div>
        <CRS:TopBar ID="Hide" runat="server" Visible="false"/>

</div>

my aspx.cs code

 if (!IsPostBack)
        {


            //Label lb = (Label)Hide.FindControl("lbl1");
            // Response.Write("---" + lb.Text);

            //HiddenField hf = (HiddenField)Hide.FindControl("hidden1");
            //Response.Write("---" + hf.Value);
            // UserControl control = (UserControl)LoadControl("Demo.ascx");

            Demo uc = (Demo)Page.LoadControl("Demo.ascx");
            // HiddenField hf1 = (HiddenField)control.FindControl("hidden1");
            HiddenField hide = (HiddenField)uc.FindControl("hidden1");
            Response.Write("--- " + hide.Value + " Value ");
            form1.Controls.Add(uc);
        }

Now How should I get the Value of HiddenField i.e. hidden1.value="123" in this aspx.cs page?


You can pass the value of hidden field to a view state property. so you can set or get the value of hidden fields.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜