Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using jquery auto complete textbox to search Username.Also I store userID in the label by using the jquery.When I am running the application, userid will appear in the label control.But when I try to use this label.text for insertion purpose, it is showing an empty string.How can I get the label text in the aspx.cs page also..It s great pleasure to get a solution on this

Thanks in advance
Posted
Updated 19-Feb-13 2:28am
v2
Comments
ZurdoDev 19-Feb-13 8:44am    
Can you share your code? Use the improve question link and post the relevant code, both jquery and C#.
Sandeep Mewara 19-Feb-13 9:18am    
One cannot comment wihtout seeing what have you implemented so far. Share the related code snippet - use Improve Question to edit/update question.
P_Dash 19-Feb-13 10:23am    
Plz share code what have you used till now.
Without seeing code it'd be hard to come to any solution.

1 solution

I guess when page is postback then Label text property is overridden by page_load/page_init event. you just check it and if needed add page.IsPostBack condition before update text property.i.e

JavaScript
<script type="text/javascript">
  function setValue(){
    $("[id*=lblData]").text("100");
  } 
</script>


<input type="button" id="btnSetValue" value="Set Value" onclick="setValue();" />


C#
protected void page_load(object sender, EventArgs e)
{
   if(!base.IsPostBack){
      lblData.Text = string.empty;
   }
}


access this property from a button event handler
C#
protected void btnSave_Clicked(object sender, EventArgs e)
{
     string value = lblData.Text;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900