Get vbhtml code to execute from html - razor

Hi Experts.  

I have code in the code section of my vbhtml, say

dim a as integer
dim b as integer
dim result as integer = a + b

a and b are dynamic so I want to add a button to the html that will show "result" in a label when the
button is clicked to update result

I think I'm trying to say I want an html button that will activate code

Any Ideas?
LVL 2
PNRTAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeroen TimmermansCommented:
<form>
<input name="valueA">
<input name="valueB">
<input type=submit>
</form>

and in your code:
a = Request.Form("valueA");
b = Request.Form("valueB");
dim result as integer = a + b;

Untested code, just a crude guideline to where you seem to be going
0
PNRTAuthor Commented:
Many thanks, I get the input boxes and the submit button which I assume adds up a and b, but how would I show "result" on the page.  I don't get result when clicking the button.  I have this so far     Thanks again

 dim a As Integer = Request.Form("valueA")
 dim b As Integer = Request.Form("valueB")
 dim result as integer = a + b

<form>
 <input name="valueA">
 <input name="valueB">
 <input type=submit>
 </form>
0
Jeroen TimmermansCommented:
<div>@{result}</div>
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

PNRTAuthor Commented:
No luck I'm afraid.
@result shows zero when the page loads.  
Entering values and clicking refreshes the page, empties a and b boxes and then still shows zero
Maybe the page refresh is a problem?
0
Jeroen TimmermansCommented:
Try this:
In your controller:
Public Function Index(ByVal a As Integer?, ByVal b As Integer?) As ActionResult
            dim a as integer
dim b as integer
dim result as integer = a + b
            Return View(result)
        End Function

Open in new window


In your Index.vbhtml:
@ModelType Integer
....
<div>@{Model}</div>

Open in new window

0
PNRTAuthor Commented:
Sorry, how would I call the function?
0
Jeroen TimmermansCommented:
As you would any other action.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.