fill 2 form one field in common with C# - c#

I need to fill two forms on the same website, my issue is the field because they have the same name, e.g. the password field in both forms is passed, so how can I fill both?
<form action="post.php" method="post">
<input type="hidden" name="name" value="value" />
<input type="text" name="image" />
<input type="password" name="pass" size="10" tabindex="7" accesskey="Q" value="">
</form>
<form action="post2.php" method="post">
<input type="hidden" name="name" value="value" />
<input type="text" name="image" />
<input type="password" name="pass" size="10" tabindex="4" accesskey="P" value="">
</form>
the code to fill fields I'm using is this:
WebBrowser1.Document.GetElementById("pass").SetAttribute("value", stringpassword);
thanks

The id attribute specifies a unique id for an HTML element.
The id must be unique within the HTML document.
The id attribute can be used by a JavaScript (via the HTML DOM) or by CSS to make changes or style the element with the specified id.
And if your specified website is not following the standard Html practices then you should write your own custom
code to access those controls and fill them straight away. You can use Regex Or Xpath for accomplishing this purpose.

Related

How to avoid #Html.CheckBoxFor generating hidden field?

Using #Html.CheckBoxFor generates a hidden field. Is there a way I can avoid generating that ?
Why I want to do that ? I was provided design, which has some script or library used in it for visual display. It works fine if Html is in below format (Checkbox with Label):
<div>
<input type="checkbox" value="resources" id="resources" class="cb">
<label for="resources">
I need an offset facility
</label>
<i class="tooltip-icon" data-icon="repayments"></i>
</div>
But it do not work if there is a hidden field between Checkbox and Label:
<div>
<input id="HomeLoanLead_Redraw_flexibility_Value" class="cb" type="checkbox" value="true" name="HomeLoanLead.Redraw_flexibility_Value" data-val-required="The Redraw_flexibility_Value field is required." data-val="true">
<input type="hidden" value="false" name="HomeLoanLead.Redraw_flexibility_Value">
<label for="HomeLoanLead_Redraw_flexibility_Value"> I want to make extra repayments </label>
<i class="tooltip-icon" data-icon="loan"></i>
</div>
If I try using <input type=checkbox> I m afraid I will not get out of box model binding in post action.
Please help.

HttpContext.Current.Request.Form checkbox

I am posting my form to an MVC Controller, where I want to process some changes the user has made on a grid like html structure.
I have checkboxes rendered as simple HTML in my View for each row :
<input type="checkbox" id="cbxR1" checked="checked" />
<input type="checkbox" id="cbxR2" checked="checked" />
I would like to know how I would retrieve a checkbox value after an AJAX post.
I am trying to use the following to retrieve the
HttpContext.Current.Request.Form["cbxR1"]
and am always getting a null, regardless of whether the checkbox was checked or not.
The cbxR1, cbxR2 should be the name of an input element, not the id.
<form ...>
<input type="checkbox" name="cbxR1" checked="checked" />
<input type="checkbox" name="cbxR2" checked="checked" />
</form>

How to send data from one page to another page with querystring and input form?

I am working in C#(asp.net). I have two pages 'abc.aspx' and 'xyz.aspx'. I want to send data from 'abc.aspx' to 'xyz.aspx'. I am using this code.
In 'abc.aspx'
<form action='xyz.aspx?site=google&code=123' method='get'>
<input type='text' name='name1' />
<input type='submit' value='submit' />
</form>
Now, I want to access all three values (site,code and name1). But, in 'xyz.aspx', I got only one value i.e name1. How to get all three values.
You need to put the values into hidden <input /> elements and hard-code the values if you want to have them end up in the query string. You're correct in setting the method='get':
<form action='xyz.aspx' method='get'>
<input type='hidden' name='site' value='google' />
<input type='hidden' name='code' value='123' />
<input type='text' name='name1' />
<input type='submit' value='submit' />
</form>
I think this one is the best.
In abc.aspx
<form action="xyz.aspx?site=google" method="post">
<input type="text" name="name1" />
<input type="submit" value="Submit" />
</form>
In xyz.aspx, access the data like this..
string site = Request.QueryString["site"];
string name = Request.Form["name1"];
//Remaining code...

Reading parameters like signup[product][handle] in ASP.NET

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));

paypal donation button integration in asp.net c#

it is required to integrate the paypal donation button in asp.net c# web form, on clicking the donate button an email should be sent to the receiver with capturing the details of the donor like donor name, occupation, address and donation amount etc.
Please any help from anyone will be appreciated.
thanks
First u go through with Paypal Documentaion... It is best source for to learn all the things which u require.
Paypal SDK Documentation
DOnation of paypal using Asp.Net : Custom Control
How to Use Paypal SDK.. Sample applicaiton.
Use this code for asp.net page for a simple donation button
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemail">
<input type="hidden" name="item_name" value="Item name">
<input type="hidden" name="item_number" value="Item ID">
<input type="hidden" name="amount" value="12.00">
<input type="hidden" name="buyer_credit_promo_code" value="">
<input type="hidden" name="buyer_credit_product_category" value="">
<input type="hidden" name="buyer_credit_shipping_method" value="">
<input type="hidden" name="buyer_credit_user_address_change" value="">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input name="cbt" value="Click here to confirm the payment" type="hidden"/>
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input name="CANCELURL" value='<%=errorurl %>' type="hidden"/>
<input name="return" value='<%=url %>' type="hidden"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
'errorurl' and return url 'url' can be defined from codeback.
Also you can avoid unwanted parameters from the code.
You can set a custom image in the 'img' tag of the code.
Create a button of your own by using this link
https://www.paypal.com/cgi-bin/webscr?cmd=_donate-intro-outside
Resources mentioned are pretty good. To go through a live-setup example, you can visit this LINK and learn how you can achieve the same on your website.
NOTE: PayPal is integrated within a website, and doesn't offer a one-click solution like Web-API.

Categories