I’m working on an application that connects to a serial port. I have experience in C#, but not so much in asp.net.
I have a Label on an aspx page which displays the status of the connection. When I click a button, a new page opens which let’s you select the serial port you want to use. When you press the OK button on that page, it will send you back to the original page with the label.
Initially, the label says: “Status: Not connected”. I’m saving this string in a globaldata class so I can access the string. I want that when you click the OK button on the new page, it will change the label to “Status: Connected”, so when the original page loads the label will be changed.
So in the OK button I added onclick="butOK_Click" and then in the event I change the string in the globaldata class. However, I don’t know how to get back to the page. Adding a PostBackUrl="Home/Index" (where Home/Index is the begin page with the label) does return to the begin page, but doesn’t execute the code that changes the string.
How can I achieve what I want?
EDIT: now that I think about it, I only want to change the label after executing a function that actually connects to the serial port. I already have this function, it just needs to let the page know that it is connected.
1 Answer