I am having a signup page at the upper of the page there is a form tag that is runat server. I want to add a code that is given by paypal take payment. That code contains a simple html controls not asp.net controls but when i paste to the code to the page then it don't submit it to the action it postback the form and don't do with paypal code at all. when i checked the source of the code it doesn't shows the from tag given by the paypal. it doesn't rander the form given by the paypal. I also have to take the form at top because my page has asp.net controls that's why that is necessary.
Please tell the solution
You must not use asp.net form tag in asp.net while payment processing.
Use this
<body onload="document.paypal.submit();">
<form name="paypal" action='<%= ConfigurationManager.AppSettings["PayPalSubmitUrl"] %>'
method="post">
// rest html goes here
</form>
</body>
I always do it like this for paypal processing
I assume you are using PayPal Standard.
If so, collect submitted values from (regular ASP.Net) form. Then forward them to PayPal like this -
protected void SubmitRadButton_Click(object sender, EventArgs e)
{
string paypalUrl = IsTestMode ?
"https://www.sandbox.paypal.com/us/cgi-bin/webscr" :
"https://www.paypal.com/us/cgi-bin/webscr";
var builder = new StringBuilder();
builder.Append(paypalUrl);
builder.AppendFormat("?cmd=_xclick&business={0}", EmailTextBox.Text);
builder.Append("&lc=US&no_note=0¤cy_code=USD");
builder.AppendFormat("&item_name={0}", ItemNameHiddenField.Value);
builder.AppendFormat("&amount={0}", AmountTextBox.Text);
builder.AppendFormat("&return={0}", ReturnUrl);
builder.AppendFormat("&cancel_return={0}", CancelUrl);
builder.AppendFormat("&undefined_quantity={0}", 1);
builder.AppendFormat("&item_number={0}", ItemNumberHiddenField.Value);
builder.AppendFormat("&cpp_header_image={0}", HeaderImage);
HttpContext.Current.Response.Redirect(builder.ToString());
}
I tried the same but didn't work. Please see my paypal code that they provided and let me know how to do this. I have tried the above method previously but this time isn't working with code. May be it is for subscription code different. Read the code following and let me know about how to use this.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="LL5LZEB8L6T8S" />
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif"
name="submit" alt="PayPal - The safer, easier way to pay online!" />
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1" />
</form>
Thanks
Related
I am new to asp.net.
My question is, can a ASP.net form with runat="server", have a method attribute in it?
For example:
<form id="form1" runat="server" method="get">
.......
</form>
Is this possible?
Thanks for your answers.
I would like to share some points which I found.
By default the form with runat="server", will have method="post".
But when we request a page for the first time, (i.e) request is not a postback, the method="get".
And it becomes method="post",while postback.
I checked this by placing a piece of code in code behind:
In Page_Load():
if(Request.RequestType=="GET")
{
Response.Write("Request is a GET type");
}
else if(Request.RequestType=="POST")
{
Response.Write("Request is a POST type");
}
By default, the output
For the first request of that page: Request is a GET type
In postback: Request is a POST type
If i give the following code in the WebForm1.aspx
<form id="form1" runat="server" method="get">
For this, the output will be:
For the first request of that page: Request is a GET type
In postback: Request is a GET type
This is what I found.
Thank you very much for your responses.
yes you can try like below.
design part
you can design a form like :
<form id="form1" runat="server" method="post">
<input type="radio" name="Gender" value="male" id="test" checked="checked" />
male
<input type="radio" name="Gender" value="female" />female
<input type="submit" value="test" />
<asp:Button ID="btn" runat="server" Text="value" />
</form>
and how to get value from the form :
if (Request.Form["Gender"] != null)
{
string selectedGender = Request.Form["Gender"].ToString();
}
with this way you can get the value from form in asp.net.
i hope it will help you.
Yes,You can use use Method attribute..
The default will be Method="Post"
The form is always submitted to the page itself. If you specify an action attribute, it is ignored. If you omit the method attribute, it will be set to method="post" by default. Also, if you do not specify the name and id attributes, they are automatically assigned by ASP.NET.
If you select view source in an .aspx page containing a form containg these properties...
Please refer : http://www.w3schools.com/aspnet/aspnet_forms.asp
I have an issue that i believe there is a simple solution for but being new to ASP.NET it is not very clear to me.
I have a user control that has a for loop that makes bunch of hyperlink elements in a list (looks like below>
<li><a href="blahblah.aspx?ID=1..../></li>
<li><a href="blahblah.aspx?ID=2..../></li>
<li><a href="blahblah.aspx?ID=3..../></li>
<li><a href="blahblah.aspx?ID=4..../></li>
Next, that uc is used in another page with in a <form> tag with method="post" and <asp:button> that isn't really used.
Next, when one of the links is clicked it will go to blahblah.asp and get the ID in there via Request.QueryString
So far so good.
What i want to do though (and the reason for this post) is that i want to not use ID as a query parameter. I want to pass the ID in the body. So the link would be blahblah.aspx and it wouldn't show the ID.
What would be the best way to accomplish this. I've tried couple different ways but it's not working.
Not sure if this will work for you, but instead of using html a tags, use the asp LinkButton control. You can then handle the command event of this control so have your for loop generate the following controls (or better yet use a repeater):
<asp:LinkButton id="button1" runat="server" CommandArgument="1" OnCommand="SendToBlah" />
<asp:LinkButton id="button2" runat="server" CommandArgument="2" OnCommand="SendToBlah" />
private void SendToBlah(Object sender, CommandEventArgs e)
{
Session["ID"] = e.CommandArgument;
Response.Redirect("blahblah.aspx");
}
You can then use your session argument inside your blahblah.aspx page however you see fit.
To send the data in the HTTP body instead of the query string, you need to do an HTTP post. This is easy enough, just use a form with a hidden parameter:
<li>
<form action="blahblah.aspx" method="post">
<input type="hidden" name="ID" value="1" />
<input type="submit" value="submit" />
</form>
</li>
To get the data on the target page, use Request.Params instead of QueryString.
Now, if you want to use a hyperlink rather than a "submit" button, you can always submit the form using Javascript:
<li>
<form id="myform1" action="blahblah.aspx" method="post">
<input type="hidden" name="ID" value="1" />
</form>
Submit the form
<form id="myform2" action="blahblah.aspx" method="post">
<input type="hidden" name="ID" value="1" />
</form>
Submit the form
</li>
<script type='text/javascript'>
window.submitForm = function(id) {
document.forms[id].submit();
return false;
}
</script>
Can I make upload file form in some sandboxed WebPart for Sharepoint Online, and if I can, how can I?
I've searched a lot and found only solutions, available for Client Object Model for outside clients, there is no example how to do this with JSOM (Client Object Model for Javascript) and usual way to upload with asp:FileUpload don't work in sandbox solution, PostedFile length = 0
You do have the option of using the ActiveX STSUpld.UploadCtl control - this enables you to provide the Multi-file upload as you see in a document library.
Note that in the following - Confirmation-URL must be set (where to go when upload is done) and the destination must be set as well to an existing document library.
<script type="text/jscript">
function DocumentUpload() {
var uploadCtl = document.getElementById("idUploadCtl");
uploadCtl.MultipleUpload();
}
</script>
<input type='hidden' name='Confirmation-URL' id='Confirmation-URL' value='' />
<input type='hidden' name='PostURL' id='PostURL' value='' />
<input type="hidden" name="Cmd" value="Save" />
<input type="hidden" name="putopts" value="true" /> <!-- Overwrite files -->
<input type="hidden" name="VTI-GROUP" value="0" />
<input type="hidden" name="destination" id="destination" value="/TestDL" /> <!-- Files destination path, must already exist -->
<p style="margin-left:auto;margin-right:auto;margin-top:0px;margin-bottom:0px;text-align:center;padding:0px !important; vertical-align:top;width:100%;">
<script type="text/javascript">
try {
if (new ActiveXObject("STSUpld.UploadCtl"))
document.write("<OBJECT id=\"idUploadCtl\" name=\"idUploadCtl\" CLASSID=\"CLSID:07B06095-5687-4d13-9E32-12B4259C9813\" WIDTH=\"600px\" HEIGHT=\"250px\" ></OBJECT>");
}
catch (error) {
}
</script>
<asp:Button runat="server" accesskey="O" id="OKButton" CssClass="ms-ButtonHeightWidth" OnPropertyChange="if (this.value != 'Upload files') this.click();" Text="Upload files" UseSubmitBehavior="False" OnClientClick="DocumentUpload(); return false;" />
<asp:Button runat="server" accesskey="C" id="CancelButton" CssClass="ms-ButtonHeightWidth" Text="Cancel" UseSubmitBehavior="False" OnClientClick="window.location ='<somewhere to go>'; return false;" />
Hope this helps....
After some search I finally found solution, based on Codeplex's SPServices. There is plugin SPWidgets(https://github.com/purtuga/SPWidgets/). This plugin loads an iframe with upload.asmx (Sharepoint's default upload form), then set display: none for all elements on this page, exept input[type=file] and adds button, wich can submit form in iframe. After submit plugin catches iframe state (_onIFramePageChange event) and do some callbacks depends on iframe url.
This looks like some ugly workaround, but it is only working solution that I found after hours of search.
There's not too many options, however check out SPServices on CodePlex - this would be the best place to start. Remember - SharePoint expects a binary object when calling the service. You have to capture the file and convert it to binary first, then call the web service to upload.
I have an example but not with me at current location - if the above doesn't get you started, let me know and I will find and post.
I'm really new to ASP and have a project where I need to capture the login of the person logged into Sharepoint. I have created the following code and am able to get the login. I am having trouble pass the parameter to a form. What is the best way to do this: I know the 2nd part the POST is wrong, I don't know what to do here. Thanks for your help. Scott
<script language="C#" runat="server">void Page_Load(Object sender, EventArgs e)
{
string userName = "NA";
userName = HttpContext.Current.User.Identity.Name;
string userWithoutDomain = userName.Substring(userName.IndexOf('\\') + 1);
myuserid.Text = userWithoutDomain;
}
</script>
<html>
<body>
<form method="POST" action="http://srs.xxx.edu:9001/signon/authenticate.asp" id="myuserid" name="myuserid">
<input type="hidden" name="COOKIEPATH" value="/SRS/">
<input style="width:70px;font-size:8pt;" size="8" name="myuserid" >
<input style="width:70px;font-size:8pt;" size="8" name="myuserid" >
<input class="button" type="submit" value=" Log On " style="display:none;">
</form>
<form id="form1" runat="server">
<asp:label id="myuserid" runat="server" />
</form>
</body>
</html>
You can pass values from the codebehind to html page using for example hidden values, see here.
Usually though values are placed into form elements in the codebehind directly. If the element has the "runat=server" attribute then you can access the element in the Page_Load method using c# and just set the text value directly.
myuserid.Text =
I have a child page LoginContent.aspx which contains a login form. If the user logs in he should be redirected to my Welcome.aspx page. But if I press the login button the page just reloads itself, nothing happens.
The codebehind on this page is empty. Both LoginContent.aspx and Welcome.aspx are child forms of the same master page.
<form method="post" action="~/Welcome.aspx">
Username: <input type="text" name="username" size="15" /><br />
Password: <input type="password" name="passwort" size="15" /><br />
<input type="submit" value="Login"/></p>
</form>
I know I could use the asp.net login control but I want more control over things.
You can't have nested form inside aspx page.
UPDATED:
Since ASP.NET webform doesn't allow us to have multiple form in one aspx page, thus in order to make it works, do the following:
Remove the form tag
add runat server to
the input perform redirect in the server side
.
Username: <input type="text" name="username" size="15" runat=server /><br/>
Password: <input type="password" name="passwort" size="15" runat=server /><br/>
<input type="submit" value="Login" runat=server onclick="submit_onclick" /></p>
And in the code behind:
protected void submit_onclick(object sender, Event e)
{
// do some auth stuff here
Response.Redirect("~/welcome.aspx");
}
Hope this will answer your question.. :)
If your <form> tag from your LoginContent.aspx nested inside your <form runat="server"> I would try moving it so it sits outside the server-side form and see if it works from there.
It might be worth tracking the HTTP requests in the Net panel of Firebug as well, just so you can see if it is actually making the HTTP POST request to /Welcome.aspx - it might help you pinpoint exactly where the problem is.