Placing C# into an ASP.net Form
-
I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.
<%if (Roles.IsUserInRole("FullMember") == false)
{%>I want to place
<% item.price%>
Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks
-
I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.
<%if (Roles.IsUserInRole("FullMember") == false)
{%>I want to place
<% item.price%>
Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks
Do you mean this
<input type="hidden" name="amount" value="<%= item.price %>" />
Help people,so poeple can help you.
-
Do you mean this
<input type="hidden" name="amount" value="<%= item.price %>" />
Help people,so poeple can help you.
Yes I do, but it doesnt work when I do that.
-
Yes I do, but it doesnt work when I do that.
where is the object item is declared? and what exception the code throw?
Help people,so poeple can help you.
-
where is the object item is declared? and what exception the code throw?
Help people,so poeple can help you.
The object is been declared from the View when it is brought in from the model. I can access the item.price object from outside the
, it might just be a basic miss understanding. value="50.00" I would like to be able to have value= <%item.price>% or something similar. Thanks
<% foreach (var item in Model) { %> <%= Html.Encode(item.Id)%> <%= Html.Encode(String.Format("{0:F}", item.Name))%> <%= Html.Encode(item.Description) %> <%= Html.Encode(String.Format("{0:F}", item.Price)) %> <%if (Roles.IsUserInRole("FullMember") == false) {%>  <%} else { %> <%=Html.ActionLink("Read", "ViewItem", "item", new {itemID = item.Id,itemName = item.Name, itemDescription = item.Description, itemFullArt = item.FullArt, itemPrice = item.Price }, nul
-
The object is been declared from the View when it is brought in from the model. I can access the item.price object from outside the
, it might just be a basic miss understanding. value="50.00" I would like to be able to have value= <%item.price>% or something similar. Thanks
<% foreach (var item in Model) { %> <%= Html.Encode(item.Id)%> <%= Html.Encode(String.Format("{0:F}", item.Name))%> <%= Html.Encode(item.Description) %> <%= Html.Encode(String.Format("{0:F}", item.Price)) %> <%if (Roles.IsUserInRole("FullMember") == false) {%>  <%} else { %> <%=Html.ActionLink("Read", "ViewItem", "item", new {itemID = item.Id,itemName = item.Name, itemDescription = item.Description, itemFullArt = item.FullArt, itemPrice = item.Price }, nul
Have you tried this
<input type="hidden" name="amount" value="<%= item.price %>" />
, this
<input type="hidden" name="amount" value="<% item.price %>" />
or none.
Help people,so poeple can help you.
-
I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.
<%if (Roles.IsUserInRole("FullMember") == false)
{%>I want to place
<% item.price%>
Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks
try this <input type="hidden" name="amount" value=<%:item.price%> you need to add after % : in your code :)