Developer forum

Forum » Development » onClick event in Razor?

onClick event in Razor?

Dmitrij Jazel
Reply

Hej Guys,

Wanted to ask you if by any chance someone tried to do something like this?

I have a Submit button, and/or a plain link

<a href="#" class="clickButton" passthis="secret message" >Secret message</a> 

What I want is get the value of passthis attribute (in this case). I can also use value of a "input type="submit" ". Just anything chat can pass a value to razor in one or another way?

 

Thanks allot for help!

Regards,

Dmitrij

 


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

You can use forms like in any other web coding using GET or POST and catch the input using Request.Querystring or Request.Form or just Request.

 

You typed "@Dynamicweb.Input.Request("myInputBox")" in your text box...<br />
<form method="get">
	<input type="text" name="myInputBox" value="" />
	<input type="submit" />
</form>
Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hej Nicolai :)

Hehe. This is Almost what I needed, but still thanks, this snippet actually did what I needed. So thanks allot for that one! ;)

 

But still, can we somehow do the same thing (pass value to razor) without form submit or DW tags involved? :)

Regards,

Dmitrij

 

 

 
Nicolai Høeg Pedersen
Reply

Yes. Razor is working just like asp, php, jsp, asp.net etc in terms of Get and Post....

 

You might want to read some basic stuff:

http://www.w3schools.com/tags/ref_httpmethods.asp

Querystrings:

http://www.w3schools.com/asp/coll_querystring.asp

http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx

Posts/Request.Form:

http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx

 

So in my previous example, without using a form, simply link to

Default.aspx?ID=PageIDofPageWithRazorTemplate&myInputBox=whateverValue

 

You must be logged in to post in the forum