Articles → LIGHT SWITCH 2011 → Textchanged event of textbox control in lightswitch 2011

Textchanged event of textbox control in lightswitch 2011


























Software requirement











Prerequisite knowledge













Create a new screen





Click to Enlarge


Add data items in screen





Click to Enlarge


Drag data items on the screen





Click to Enlarge


Change control type of data item





Click to Enlarge


ControlAvailable event on Created method




partial void TextChangeDemo_Created()
{
   this.FindControl("Message").ControlAvailable += new EventHandler<ControlAvailableEventArgs>(TextChangeDemo_ControlAvailable);
}

void TextChangeDemo_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
   throw new NotImplementedException();
}



Register textchanged event




void TextChangeDemo_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
   if (e.Control is TextBox)
   {
      TextBox txt = (TextBox)e.Control;
      txt.TextChanged += new TextChangedEventHandler(txt_TextChanged);
   }
}

void txt_TextChanged(object sender, TextChangedEventArgs e)
{
     throw new NotImplementedException();
}









Register textchanged event




void txt_TextChanged(object sender, TextChangedEventArgs e)
{
  TextBox txtControl = (TextBox)sender;
  this.MessageCount = txtControl.Text.Length.ToString();
}



Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, July 17, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250