Source view of HIDDENFIELD.ASPX
DotNet Funda: Code Viewer
hiddenfield.aspx | hiddenfield.aspx.cs
Close Window  
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
    <table width="100%" cellpadding="2" cellspacing="0">
        <tr valign="top" class="ArticleTitle">
            <td style="padding-left:10px;" valign="middle">
                asp:HiddenField control</td>
        </tr>
        <tr>
            <td class="ArticleContents">
                HiddenField is used to create a hidden field in the form.
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
    <div class="ArticleContents">
        Ideally HiddenField is used to create a hidden field in the form.
        When it is rendered on the page, it is implemented through &lt;input type=hidden&gt; HTML tag.
        <!-- START - Demo Section -->
        <table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
            <tr>
                <td class="DemoTitle">
                    DEMO : HiddenField
                </td>
                <td align="right">
                    <a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/controls/hiddenfield.aspx" target="_blank">Show Source Code</a>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:HiddenField ID="hiddeFieldValue" runat="Server" Value="This is the Value of Hidden field" />
                    <asp:Button ID="btnSubmit" runat="Server" OnClick="ChangeLabelText" Text="Change Label Text to Hiidden Field Value" />                
                </td>
                <td>
                    Ex. <asp:Label ID="Label1" runat="server" BackColor="Coral" ForeColor="blue" BorderColor="ActiveBorder" BorderStyle="dashed" BorderWidth="1" Height="20" Text="Example of Label Control" Width="200" ></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <!-- START - Server Side Code -->
                    <pre>
            &lt;asp:HiddenField ID="HiddenField1" runat="Server" Value="This is the Value of Hidden field" /&gt;
            &lt;asp:Button ID="Button1" runat="Server" OnClick="ChangeLabelText" Text="Change Label Text to Hiidden Field Value" /&gt;                                        
                    
            // CODE BEHIND
            // Fires when Button is clicked
            protected void ChangeLabelText(object sender, EventArgs e)
            {
                Label1.Text = hiddeFieldValue.Value;
            }
                    </pre> 
                    <!-- END - Server Side Code -->
                </td>
            </tr>
        </table>
        <!-- END - Demo Section -->
        </div>
    <br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server">
</asp:Content>

Go Top