0

Converting Classic ASP page to C#/ASP.NET. I am building part of a mouseover menu (Here is Classic ASP code):

<li onmouseover="LoadSubMenu('menu6');"><a id="menu6btn" href="<%=application("URLroot")%>/OURtraining/">Training</a></li>

Notice its calling the function, LoadSubMenu and pulling the URLroot value from the application object. I can get these things in the C# page using a method. How can I call the method from the C# page? If your going to suggest a Javascript solution, please over simplify (I am weak on Javascript). Thank you in advance for your help.

pmcs
  • 51
  • 1
  • 10
  • No mater how much they may look like a GUI, ASP.Net Page are still just a 1980 HTML WebFormular. So wich button was pressed has to be send along with the postback, and there is only one way to do that. ASP.Net takes care of all the "plumbing" and will raise the proper "ButtonClick" even during postback processing. – Christopher Aug 03 '19 at 13:40
  • I finally managed to find this old Page Lifecycle explanation. It does explain all the "Automagic" things it does for you. https://learn.microsoft.com/en-us/previous-versions/ms178472(v=vs.140) – Christopher Aug 03 '19 at 13:42
  • As far as I understand(never had to work with classic ASP) onmouseover is a regular https://www.w3schools.com/jsref/event_onmouseover.asp, so it should be regular JavaScript. As for `application("URLroot")` the answer is probably https://stackoverflow.com/questions/5853294/how-do-i-get-the-site-root-url – Eugene Podskal Aug 03 '19 at 13:45
  • Hi, I dont have a problem getting the Application object in the code behind. How do I get it onto the .aspx page? As you can see, in classic ASP, they can just use: <%=application("URLroot")%>, but you cant do that in ASP.NET. I need to be able to return a value from a C# method (same with LoadSubMenu('menu6'). I think it can be done in Javascript, but I am not sure how. – pmcs Aug 03 '19 at 14:09
  • Christopher, Thanks, but how am I raising a button click event? I need to be able to call a method from the .aspx page (similar to how its done in the classic asp page. – pmcs Aug 03 '19 at 14:15

0 Answers0