I'm making a web application using MVC3 with C#
I would like to get the checkboxes in my view defined as:
<input type="checkbox" name="group1[]" value="1" />
<input type="checkbox" name="group1[]" value="2" />
<input type="checkbox" name="group1[]" value="3" />
to be available as an List of values in the formCollection of a post method.
When I put a breakpoint it looks like the "group1" entry in the formCollection is indeed a list but I don't know how to get it using the formCollection.Get method.
<input type="checkbox" name="group1[0]" value="1" />
<input type="checkbox" name="group1[1]" value="2" />
<input type="checkbox" name="group1[2]" value="3" />
Try using this
Related
Is it possible to get the value attribute in any of these input tags by targeting the name attribute using HtmlAgilityPack?
<form>
<input type="hidden" name="name" value="1" />
<input type="hidden" name="description" value="2" />
<input type="hidden" name="address" value="3" />
<input type="hidden" name="phone" value="4" />
<input type="hidden" name="email" value="5" />
</form>
This code can get the third element in the form using elements[2]. But if either of the first two elements are missing, it will break. Is it possible to target the third element's value attribute using the name attribute in the HTML?
var doc = new HtmlDocument();
doc.Load(myHTMLFile);
var form = doc.DocumentNode.SelectSingleNode("//form");
var elements = form.SelectNodes("//input");
var name = elements[2].Attributes["value"].Value,
//input[contains(#name, 'address')]
This should work... sorry about the short answer. On mobile
Currently, We are assigning the values in the below form and post the data to payfort. Which works fine!!
<form method="post" action="https://sbcheckout.payfort.com/FortAPI/paymentPage" id=form1 name=form1>
<input type="hidden" name="signature" />
<input type="hidden" name="command" />
<input type="hidden" name="merchant_reference" />
<input type="hidden" name="amount" />
<input type="hidden" name="access_code" />
<input type="hidden" name="merchant_identifier" />
<input type="hidden" name="currency" />
<input type="hidden" name="language" />
<input type="hidden" name="customer_email" />
<input type="hidden" name="payment_option" />
<input type="hidden" name="order_description" />
<input type="hidden" name="return_url" />
But when we post the data throw above method it shows the credential information to others
Is there any way that we can post the data to payfort from our controller and redirect to posted URL ?
You can use: https://github.com/payfort/payfort-dotnet-sdk/
this is official dotnet SDK from payfort
Yes you can post data to payfort using .Net Client library https://github.com/payfort/start.net
steps to call payfort.
1) Generate card Token
pass open key and card detail.
2) create charge using card token
3) capture charge amount
I'm trying to get my Buy Now button in PayPal Sandbox to work. However when I make a purchase using it, it does not show up on my business transaction overview. And in the personal account, it shows as "Unclaimed" and "The recipient of this payment is Unregistered". Here is the ASP.NET code I'm using for the button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="notify_url" value="censored" />
<input type="hidden" name="item_name" value="Aktivt kontigent" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="amount" value="240" />
<input type="hidden" name="tax_rate" value="25" />
<input type="hidden" name="undefined_quantity" value="0" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="handling" value="5" />
<input type="hidden" name="business" value="censored" />
<asp:ImageButton ID="btnPayNow" runat="server" ImageUrl="~/images/btn_buynowCC_LG.gif" PostBackUrl="https://www.sandbox.paypal.com/cgi-bin/webscr"/>
</form>
I know I'm using the right business ID, because my Business name appears on the checkout page on PayPal. And the IPN is also working, I can see that on my server. However the transaction does not appear on seller account, and the personal account is having this weird status. Does anyone know how to fix this please?
Thank you in advance.
The problem with this was my e-mail was not veryfied. It worked after that.
I need to read parameters from Context.Request that is written in a format like:
url?event=open&signup[customer][first_name]=John&signup[customer][last_name]=Doe&signup[payment_profile][card_number]=xxxxxxxx
Is there an easy way to parse this into a c# object? Would it be recommended to parse this in to a NameValueCollection, or is it to complex?
I am not familiar with this way of posting data, I don't even know what it is called when you do it like this, anyone care to fill me in? Thanks!
In case you are interested, this is the way stuff get posted:
<form method="post" action="https://....">
<input type="hidden" name="signup[product][handle]" value="basic" />
<input type="text" name="signup[customer][first_name]" />
<input type="text" name="signup[customer][last_name]" />
<input type="text" name="signup[customer][email]" />
<input type="text" name="signup[payment_profile][first_name]" />
<input type="text" name="signup[payment_profile][last_name]" />
<input type="text" name="signup[payment_profile][card_number]" />
<input type="text" name="signup[payment_profile][expiration_month]" />
<input type="text" name="signup[payment_profile][expiration_year]" />
<input type="submit" value="Sign Up" />
</form>
You can parse the query string into a NameValueCollection this way:
var nvc = new NameValueCollection();
nvc.Add(HttpUtility.ParseQueryString(Request.Params));
I have been trying out the NameValueDeserializer from MVCContrib, which will take a IList as a parameter to a controller and bind a form and its elements to it, but I was just wondering if MVC Beta had any way of doing this??
I know you can bind a strongly typed Object but I want to bind a List of these Objects for some bulk editing situations.
eg.
public void Save(IList<Item> items)
{
foreach (Item i in items)
{
//Save item
}
}
Is this possible in MVC Beta??
Yes it is, I wrote a detailed blog post about it here. It's really easy for simple types. For complex types, you'd need to do something like:
<input type="hidden" name="products.Index" value="0" />
<input type="text" name="products[0].Name" value="Beer" />
<input type="text" name="products[0].Price" value="7.32" />
<input type="hidden" name="products.Index" value="1" />
<input type="text" name="products[1].Name" value="Chips" />
<input type="text" name="products[1].Price" value="2.23" />
<input type="hidden" name="products.Index" value="2" />
<input type="text" name="products[2].Name" value="Salsa" />
<input type="text" name="products[2].Price" value="1.23" />