In ASp.net Page I Need To Know How To Maintain The Value Of A Particular Label Assign By the HTML Button Click. after Postback Done.
with out converting label to textbox, not using hidden field or session

Detailed Code

 <table>
        <tr>
            <td><asp:Label ID="lbl1" runat="server" ClientIDMode="Static">Before Changing</asp:Label></td>

            <td><asp:Label id="lbl2" runat="server" ClientIDMode="Static"></asp:Label></td>

            <td><asp:TextBox ID="txtbox" runat="server"></asp:TextBox></td>

</tr>

        <tr>
            <td><asp:Button ID="btnasp" runat="server"  Text="ASP Button" Height="50px" Width="150px" OnClick="btnasp_Click"/></td>

            <td><input type="button" id="btnhtml" value="HTML Button" onclick="showlabel()"  style="height:50px; width:150px"/></td>
        </tr>

    </table>

Script

 <script type="text/javascript">
    function showlabel() {
        $('#lbl1').text("After Changing");

        }
</script>

cs code

   protected void btnasp_Click(object sender, EventArgs e)
    {

        txtbox.Text = lbl1.Text;
    }

OutPut

[label"Before Changing"]                      [txtbox] 

[asp button]  [html button]

If I click HTML Button

The Label Text Before Changing Is Change To After Changing

Then I Click The ASP Button After Changing Value is show in textbox

This Is Done By With Out adding value in Hidden Field and Not Using the Server Control to Html Button,

How It Possible Plz Help Me ...

Edited 2 Years Ago by gurunathan_1: missing Some Words

i think you can add value of label in query string . and on page load event just check if it is post back then get the value from query string and set to label :P .

i think you can add value of label in query string . and on page load event just check if it is post back then get the value from query string and set to label :P .

This would of course allow it to be changed by the user by editing the URL bar, causing security implications. Not sure if that would cause problems for the OP; Depends upon what information is being maintained between pages.

Otherwise a fine suggestion.

Hi, a simple approach would be to create a property that would get and set the value(s) and then you can easily use that property value.

It would be like as follows :-

private string _myProperty = string.Empty;
public string MyProperty
{
   get 
   { 
       return _myProperty; 
   }
   set
   {
       _myProperty = myLabel.Text;
   }
}

And so it would set a public property as MyProperty and you can access the label value throughout the page.

This article has been dead for over six months. Start a new discussion instead.