How to call a Session and use it as a value of Text Box Form. I am using asp.net
<form id="frmLog" name="frmLog" method="post" action="/Page/">
<input type="text" name="UserId" value="<%=Sessiopn["UserID"] %>">" />
</form>
Thanks!
Correct it to this. You have a typing mistake.
<input type="text" name="UserId" value="<%=Session["UserID"] %>" />
you have error on variable name (without p)
Sessiopn -> Session
Related
I need to take the username, email and password a user enters in an html form (in index.aspx) and use it in an asp.net code in another page (register.aspx in a folder called 'u').
This is the form:
<form action="u/register.aspx" method="post" id="regForm">
<input type="text" name="fname" id="fname" placeholder="Full Name (Optional)" maxlength="16" />
<input type="text" name="uname" id="uname" placeholder="Username" maxlength="16" />
<input type="email" name="email" id="email" placeholder="Email Address" maxlength="32" />
<input type="password" name="pwd" id="pwd" placeholder="Password" maxlength="16" />
<input type="password" name="repwd" id="repwd" placeholder="Repeat Password" maxlength="16" />
<input type="submit" value="Sign Up" id="signup" />
</form>
But, when I'm using Request.QueryString["fname"] for example, it doesn't take 'fname' from the form, it just takes a null.
What can I do to solve this? Is there a different method I can use to achieve the wanted result?
Thanks a lot!
You are doing it wrong.
Request.QueryString contains information related to data added after ? in the URL (ex. http://www.contoso.com?mydata=1¶m2=yy).
You have to use Request.Form to access "POST" data.
QueryString will only give the parameters on the query string of the url check here.
If you want all the parameters you will need to use the Params property.
As others have already said Request.QueryString contains data after the ? in url.
You can use Request.Form or if you want the data as part of the url, you can change your form element method attribute to "get"
I've setup two pages. 1.aspx, and 2.aspx.
on 1.aspx I have a form like so:
<form action="2.aspx" method="post" id="myform">
<input type="hidden" value="this works" id="mydata" />
<input type="submit" />
</form>
on 2.aspx I have this code:
Response.Write(Request.Form("mydata"))
This returns nothing.
I also tried
Response.Write(Request.Form(0))
but I get "Index was out of range." Message from the server.
I know I'm probably missing something very simple, but, I can't seem to find it!
What am I doing wrong?
Thanks!
ID is used for client-side access. Give your hidden field name="mydata" for server-side form access
Instead of having
<input type="hidden" value="this works" id="mydata" />
have
<input type="hidden" value="this works" name="mydata" />
IF you want to keep id instead of name you have to write it out differently.
you want to use document.getElementById instead of Request.form
I have done an interswitch payment gateway in my regular asp.net webform and asp.net mvc.
But I have a requirement to do the same in dotnetnuke which i know i can through module.
In my pay now pay of my application i have a form to send data across to interswitch webservice the form is below
<form name="form1" action="https://stageserv.interswitchng.com/test_paydirect/pay"
method="post">
<input name="product_id" type="hidden" value="XX" />
<input name="pay_item_id" type="hidden" value="XX" />
<input name="amount" type="hidden" value="XXXXXXX" />
<input name="currency" type="hidden" value="566" />
<input name="site_redirect_url" type="hidden" value="http://abc.com /getresponse”/>
<input name="txn_ref" type="hidden" value=" XXXAFTXXX”" />
<input name="hash" type="hidden" value="BB292DF9268F05CB9CBBC5E0C13CC1B13ACA34DC" />
</form>
I need someone to help me out on how i can implement this in my dotnetnukes module.
I faced a similar problem and asked this question. The accepted answer here is how I ended up doing it.
I just added the input fields to the page and then changed the "Pay" buttons PostBackUrl
This way you don't need to add an additional form to the page, and when the user clicks the button, it will submit those fields, so obviously it will pick up the ones it's looking for.
So in your case it would be:
<%-- other page content before --%>
<input name="product_id" type="hidden" value="XX" />
<input name="pay_item_id" type="hidden" value="XX" />
<input name="amount" type="hidden" value="XXXXXXX" />
<input name="currency" type="hidden" value="566" />
<input name="site_redirect_url" type="hidden" value="http://ipsum.com/getresponse”/>
<input name="txn_ref" type="hidden" value=" XXXAFTXXX”" />
<input name="hash" type="hidden" value="BB292DF9268F05CB9CBBC5E0C13CC1B13ACA34DC" />
<%-- pay button would look like this --%>
<asp:Button ID="btnPayNow" runat="server" PostBackUrl="https://stageserv.interswitchng.com/test_paydirect/pay" Text="Pay Now!" />
<%-- other page content after --%>
Of course if you have multiple payment gateway options you can set the PostBackUrl programatically before you display the form: btnPayNow.PostBackUrl = "http://<url>.com"
If you are posting to another site, not even anything on your site then you don't need a module at all.
With DNN you cannot include another form on your site like that. But you could make that a .html page and include that on your site as an iframe or something like that.
That should post to that other service fine.
Basically I want to place a url in the form action method.
The ltlUrl.text value is added on the server side in pageLoad.
How do i use the ltlUrl as the action method?
<form action="<%# ltlurl.text%>" enctype="multipart/form-data">
<input type="text" name="title" value="test" />
<input type="file" name="file" />
<input type="submit" />
</form>
Since you are populating the text control on code behind, you can simply do this:
this.Page.Form.Action = "http://someour";
I believe the VB.NET syntax would be:
Me.Page.Form.Action = "http://someurl"
All the examples I can find are in Visual Basic, but I am using C#.
I want to get the data that is in a textbox in a form.
My code so far:
<form action="login.aspx" method="get">
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="text" name="password" /></p>
<input type="submit" value="Submit" />
</form>
So what could I do? Because I keep getting told to do this:
Dim UserName
UserName = Request.Form("UserName")
But it doesn't work in C#.
Don't need to do that on asp.net; simply change your markup like so:
<form action="login.aspx" method="post" runat="server">
<p>Username: <input type="text" name="username" runat="server" id="txtUsername" /></p>
<p>Password: <input type="text" name="password" runat="server" id="txtPassword"/></p>
<input type="submit" value="Submit" />
</form>
And on code behind:
string UserName= txtUsername.Value;
And yes, Shawn also caught a good one, you should use POST.
Your method should be POST.
<form action="login.aspx" method="post">
The sample code you posted is vb.net. C# has it's own syntax and keywords.
to get the value you can use the following (not an optimal solution for webforms)
string userName = Request.Form["UserName"];
I would suggest going through some c# tutorials to get a handle on the language. Here's the first one i found http://www.csharp-station.com/Tutorial.aspx