I'm using one button for "on and "off" in asp.net c#. When i click that
button it is "on" and when i click that same button second time it is
"off". Now i want to do this within one click. This means that once i
click and hold that button it should be "on" till i release the button,
when released it should be "off". Please let me know how can i do that !
- protected void Page_Load(object sender, EventArgs e)
- {
- ardo = new SerialPort();
- ardo.PortName = "COM5";
- ardo.BaudRate = 9600;
- }
- protected void BlueOn(object sender, EventArgs e)
- {
- if(Session["currentState"] == null)
- Session["currentState"] = "2";
-
- if(Session["currentState"].ToString() == "1")
- {
-
- Session["currentState"]= "2";
- }
- else
- {
-
- Session["currentState"]= "1";
- }
- ardo.Open();
- ardo.Write(Session["currentState"].ToString());
- ardo.Close();
-
- }