So, so so many questions on this, and yet I can't for the life of me find a SIMPLE answer for a SIMPLE question.
Ok, so I have an ASP MVC (c#) with razor view project (with a layout created by the great DevExpress People) - Great! :)
The Situation
I've a <button>
, and a <p>
displayed on my view - all good.
the button's ID is (funnily enough) myButton
, and the paragraph is myParagraph
.
I also have a HomeController
with a simple method of
public string updateAlerts()
{
return "THIS IS AN IMPORTANT PARAGRAPH";
}
My Question is:
Using the basics of
<button id="myButton" onclick="myFunction()">This is a button</button>
What do I need to use to call this method?
there are lots of questions stating AJAX
or JQuery
- but in all honesty, I've not the foggiest idea of how to use those! (i'm an idiot, ok?)
So I wrote a script
thing (which, to be honest, I don't think is 'fully' needed,
<script>
function myFunction(){
//how do I call this method here?
var myString = ...
document.getElementById("myButton").innerText = myString;
}
</script>
Could anyone tell me how to fill this in the simplest/easiest-to-understand way possible?
Cheers
edit
I thought this answer would help, but either i'm just stupid (probably) or doesn't suit this situation (sad face).
I also don't know if it makes a 'huge' deal, but this 'paragraph' is also situated on one of the 'panels' (left nav bar to be precised)-and so will be seen on all pages of the system