RazorGenerator not processing Html.EditorFor or Html.BeginForm - asp.net-mvc

I have the following razor code:
<form id="logon" action="/security/dev" method="get">
#Html.AntiForgeryToken()
#Html.EditorFor(x => x.UserName)
#Html.EditorFor(x => x.Password)
<input type="submit" value="Login" name="Login" />
<input type="submit" value="Cancel" name="Cancel" />
</form>
when getting the precompiled version to output the generated html I get the following:
<form id="logon" action="/security/dev" method="get">
<input name="__RequestVerificationToken" type="hidden" value="vTyswnqonYMzGeewLrLSJ9XySz1A0PR0nvyVu58458J/nftXtxBPIVoQEdfr3MzEYPDLBPcGvXtMkOTujsou/x3eJVfdt2YSJgxUfu6AxMLj23kTwUNQo7X8ec7twsbt8U2BdogpHy0fSGq1nMljlukM9fGZ/770JLijcpJXx4o=" />
/* EditorTemplates/String */
/* EditorTemplates/Password */
<input type="submit" value="Login" name="Login" />
<input type="submit" value="Cancel" name="Cancel" />
</form>
Anyone have any idea why it would do that? Here is a failing example: skydrive file
Cheers
w://

Apparently this is not part of the expected output.

I had similar problem with EditFor. Using TextBoxFor instead helped me.

Related

HTML.BeginForm not Routing to Controller Method

I'm writing an MVC website in C# with razor syntax.
I have some code here:
#using (Html.BeginForm("DoSignUp", "SignUpController", FormMethod.Post))
{
<input type="text" width="3000" value="" name="Name" />
<input type="submit" value="Register" /
}
So this form should post to the SignUpController on the DoSignUp method. Instead of doing that it just posts back to the page I'm currently on which is called SignUp. I suspected there might be something wrong with my routing but when I look at the html that is being generated through the browser developer tools i see this:
<form action="" method="post">
<input type="text" width="3000" value="" name="selectedURL">
<input type="submit" value="Register">
</form>
Edit: Well I wrote this out and then looked at my code again. The problem which I keep bloody doing is that SignUpController should just be SignUp.
Remove the 'Controller' from your controller name (SignUp, not SignUpController). It's assumed to be a controller by convention
#using (Html.BeginForm("DoSignUp", "SignUp", FormMethod.Post))
{
<input type="text" width="3000" value="" name="Name" />
<input type="submit" value="Register" /
}

Why does "<input id='id' type=text name='id' value='H123'>" not get "POST"ed by FormData

When I submit the following form
<form name="fileUpload" id="fileUpload" method="post" action="javascript:void(0);" enctype="multipart/form-data">
<input id='id' type=text name='id' value='H123'>
<div class="file_browser">
<input type="file" name="multiple_files[]" id="_multiple_files" class="hide_broswe" multiple />
</div>
<div class="file_upload">
<input type="submit" value="Upload" class="upload_button" />
</div>
</form>
The files[] get uploaded OK but input "#id" is not in the $_POST array.
I need it because I want to pass the name of the directory that the images are to be stored in.
I notice that you are missing quotation marks around 'text' in
<input id='id' type=text name='id' value='H123'>
Which should be:
<input id='id' type='text' name='id' value='H123'>
Besides that I can't see any obvious reason why it shouldn't work.

Google+ Sign-In hybrid with spring-security

to enabling OpenID authentication with Spring Security
We can add OpenID to the login page as follows:
`
<form action="j_spring_openid_security_check" method="post">
<input name="openid_identifier" size="50" maxlength="100"
type="hidden" value="https://www.google.com/accounts/o8/id"/>
<input type="submit" value="Sign in with Google"/>
</form>
for migrating to Google+ Sign-In how to integrated it with following HTML sign-in button?
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT_ID"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schema.org/AddAction"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
this solution not work
<form action="<c:url value='j_spring_openid_security_check'/>"
method="post">
<input id="openid_identifier" name="openid_identifier" type="hidden"
value="https://accounts.google.com/o/oauth2/auth?" />
<input name="scope" value="https://www.googleapis.com/auth/plus.login"
type="hidden" />
<input name="response_type" value="code" type="hidden" />
<input name="client_id"
value="*****************.apps.googleusercontent.com"
type="hidden" />
<input name="client_url" value="**********" type="hidden" />
<input name="redirect_uri" value="postmessage" type="hidden" />
<input name="origin" value="**********" type="hidden" />
<input id="openid_submit" type="submit" value="Sign-In" />
</form>

Paypal checkout page not displaying shipping/postage cost

I have gone through many questions similar to this but I could not resolve the issue. This is not the first time I am using paypal, I have successfully used the code below in other websites as well.
I have also checked the option for overriding the profile postage settings.
I am using the following code:
<form id="f1" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
#* <input type="hidden" name="shipping" value="0.00">*#
<input type="hidden" name="handling_cart" value="#shipamt" />
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="businessEmail#paypal.com" />
<input type="hidden" name="currency_code" value="GBP" />
<input name="custom" type="hidden" id="custom" value="#cartId" />
#foreach(var cartdetail in Model.cartDetail)// (int i = 0; i < Model.order.cart.cartDetail.Count;i++ )
{
<input type="hidden" name="item_number_#i" value="#i" />
<input type="hidden" name="item_name_#i" value="#cartdetail.product.Title" />
<input type="hidden" name="quantity_#i" value="#cartdetail.Quantity" />
<input type="hidden" name="amount_#i" value="#cartdetail.product.getCurrentPrice()">
i++;
}
<input type="hidden" name="return" value="http://parduh.com" />
<input type="hidden" name="cancel_return" value="http://cancelurl.com" />
<input type="hidden" name ="notify_url" value="http://notifyurl.com" />
#* <input type="hidden" name="no_shipping" value="1" />*#
<input type="hidden" name="image_url" value="http://parduh.com/images/logo.png">
</form>
These are the values from chrome's developer tool, all the values are being posted to paypal
handling_cart:16.6167
cmd:_cart
upload:1
business:mybusinessemail#hotmail.com
currency_code:GBP
custom:13
item_number_1:1
item_name_1:Dress
quantity_1:1
amount_1:68.00
Thanks for the help.
The issue is that you are passing the value for handling_cart with more than 2 decimal places. Try the same request, but making sure that you round off so that handling_cart = 16.62.

Accessing HTML tags in a RUBY Controller

I have the following code in my HTML.erb
<form>
<input id="do" type="hidden" value="0" />
<button type="submit" value="Next">SUBTRACT</button>
</form>
<form>
<input id="do" type="hidden" value="1" />
<button type="submit" value="Next" >ADD</button>
</form>
Now When I click the any of the 2 buttons, I want to check the value of the input id="do" inside my Ruby Controller. What would the syntax look like ?
This should optimally be separated into two actions in the controller where each of the forms would submit (using the action attribute).
<form action='add'>
<input id="do" type="hidden" value="0" />
<button type="submit" value="Next">SUBTRACT</button>
</form>
<form action='subtract'>
<input id="do" type="hidden" value="1" />
<button type="submit" value="Next" >ADD</button>
</form>
#in your controller
def add
# do the addition processing
end
def subtract
# do the subtraction processing
end
If you really need to implement them in 1 action, then you could use Rails params object.
You need to set the name attributes, the name attributes get sent to the controller in the params hash
<form>
<input id="do" name="subtract" type="hidden" value="0" />
<button type="submit" value="Next">SUBTRACT</button>
</form>
<form>
<input id="do" name="add" type="hidden" value="1" />
<button type="submit" value="Next" >ADD</button>
</form>
In the controller,
the params[:subtract] or params[:add] will have the value depending on subtract clicked or add clicked .

Resources