TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Faisal
NA
73
1.6k
On="1" and Off="2" within one click
Aug 6 2019 11:47 PM
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();
}
Attachment:
Arduino_Csharp_DOTnet_webcontrol_ON_OFF_WITHIN_ONE_BUTTON.rar
Reply
Answers (
3
)
Uploading file in MVC under Debug forces program to exit
Error While Integrating API ?