By using WebClient in C#, I can get the source of a page. Imagine that this HTML source always contains a form with a given name like this:
<form name="myform" action="page.php">
<input type="text" name="mytext" value="default text">
<textarea name="mytextarea">content</textarea>
<input type="password" name="mypass" value="12345">
<input type="hidden" name="myhiddenfield" value="code">
<input type="checkbox" name="mychb1" value="true" checked>
<input type="checkbox" name="mychb2" value="true">
<input type="radio" name="myradio" value="radio2" checked>
<input type="radio" name="myradio" value="radio1">
<select name="mychoice">
<option value="cherry">cherry</option>
<option value="orange">orange</option>
<option selected="" value="apple">apple</option>
</select>
<input type="submit" value="Submit">
</form>
Now I want to make POST data according to these values like this:
mytext=default text&mytextarea=content&mypass=12345&myhiddenfield=code&mychb=true&myradio=radio2&mychoice=apple
Note that mychb2 is not included because is not checked and also the names might be vary in each page source and there might be more or less than elements in the forms.
How can I do this?
Related
I have a list of 100+ textboxes on my page. I want to have one textbox at the top that can change all of them to its value, yet still have the others able to be independent (as in, using one variable for all wouldn't work). They should be able to be changed individually, with the master one sort of acting as a "Change All".
My question is, would this work better by looping through and doing a postback in c#? Or can I dynamically change them all in jquery? Which would you recommend?
I would highly recommend changing them all with jquery. It could be as simple as something like this:
$('#txt_Master').change(function() {
$('.childTextBoxes').val($(this).val());
});
Using jQuery would be the best option.. As there is too much of load using the server side controls..
Check this FIDDLE
<input type="text" class="master"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
<input type="text" class="child"/>
$(document).ready(function() {
$('.master').on('change', function() {
$('.child').val( $(this).val() );
});
});
my query is , i have a combo box inside my form in html , i would like to pass the value of the selected item of the combo box to the server side which is a aspx page,
<form method="POST" action="page.aspx">
<input id="customerName" name="customerName" type="Text" />
<input id="customerPhone" name="customerPhone" type="Text" />
<select id="combobox" >
<option>df</option>
<option>as</option>
</select>
<input
</form>
value="Save" type="Submit" />
in the server side i use the following set of codes to select the textbox value
string n = String.Format("{0}", Request.Form['customerName']);
but how to get the values of the combo box selected value
please help me
thanks in advance
You can try fixing your html:
<form method="POST" action="page.aspx">
<input id="customerName" name="customerName" type="text">
<input id="customerPhone" name="customerPhone" type="text">
<select id="combobox" name="combobox">
<option value="df">df</option>
<option value="as">as</option>
</select>
<input value="Save" type="submit">
</form>
The selected value will be posted as Request.Form['combobox']
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));
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.
I have a website with all my photos, I would like people to be able to click on my pictures and order prints, etc through a third party service (Shutterfly, etc). Does anyone have any best practices or code examples of doing this in C#, ASP.NET?
I have no idea if this information is still up to date, but here is a description of the Shutterfly API. The API seems to consist in a simple HTTP form post with embedded name-value pairs.
Example:
<form action="http://www.shutterfly.com/c4p/UpdateCart.jsp" method="post">
<input type="hidden" name="addim" value="1">
<input type="hidden" name="protocol" value="SFP,100">
<input type="hidden" name="pid" value="C4P">
<input type="hidden" name="puid" value="AFFL">
<input type="hidden" name="imnum" value="1">
<input type="hidden" name="imraw-1" value="http://images.partner.com/foo/12345.jpg">
<input type="hidden" name="imrawheight-1" value="1800">
<input type="hidden" name="imrawwidth-1" value="1200">
<input type="hidden" name="imthumb-1" value="http://images.partner.com/foo/12345_thumb.jpg">
<input type="hidden" name="imthumbheight-1" value="150">
<input type="hidden" name="imthumbwidth-1" value="100">
<input type="hidden" name="returl" value="http://www.partner.com/alice">
<input type="submit" value="Submit">
</form>
It should not be a difficult task to write some C# wrapper for it.