Submit form that posts to another site - asp.net

I have an online banking login that I'm trying to take from an old client site and put on their new site. If I copy the form and paste it into my new site, it just reloads the page when submitted. I've tried to change it to an asp.net form using the appropriate and other applicable tags with the same result.
If I take the form and put it in a simple index.html file, it submits and takes me to the correct external site.
I was unable to set the ID & values with the asp.net form and that may be one of the issues.
Any help is appreciated.
Here is the HTML form version that works in .html page that needs to work in .aspx page:
<form action="some external site" method="POST" autocomplete="OFF" target="_top">
<input type="hidden" name="sssid" value="my value">
<input type="hidden" name="iid" value="another value">
<div class="field-container">
<label for="aid" id="aid-label">Access ID</label>
<input name="aid" id="aid" type="text" size="8" onFocus="toggle_label(this, 'focus');" onBlur="toggle_label(this,'blur');" />
</div>
<div class="field-container">
<label for="passcode" id="passcode-label">Passcode</label>
<input name="passcode" id="passcode" type="password" size="8" onFocus="toggle_label(this, 'focus');" onBlur="toggle_label(this,'blur');"/>
</div>
<div class="form-row">
<input type="submit" name="Submit" value="Go" class="button">
</div>
</form>
Here is my asp.net form version that I tried:
<form action="some external site" method="POST" autocomplete="OFF" target="_top">
<input type="hidden" name="sssid" value="some value">
<input type="hidden" name="iid" value="another value">
<asp:TextBox runat="server" ID="sssid" CssClass="form-control" type="hidden" ClientIDMode="Static"></asp:TextBox>
<asp:TextBox runat="server" ID="iid" CssClass="form-control" type="hidden" ClientIDMode="Static"></asp:TextBox>
<div class="form-group">
<asp:Label runat="server" id="lblAccessID"></asp:Label>
<asp:TextBox runat="server" ID="txtAccessID" CssClass="form-control"> </asp:TextBox>
</div>
<div class="form-group">
<asp:Label runat="server" id="lblPassCode"></asp:Label>
<asp:TextBox runat="server" ID="txtPasscode" CssClass="form-control" TextMode="Password"></asp:TextBox>
</div>
<button type="submit" class="btn btn-blue">GO
<img src="/Content/img/icon-sm-arrow.png" alt="" />
</button>
</form>
My asp.net form code behind:
protected void Page_Load(object sender, EventArgs e)
{
txtAccessID.Attributes.Add("placeholder", "Access ID");
txtPasscode.Attributes.Add("placeholder", "Passcode");
}

I had to use the following to post this correctly:
<asp:LinkButton runat="server" ID="btnSubmit" CssClass="btn btn-blue" PostBackUrl="urlhere" Text='GO <img src="/Content/img/icon-sm-arrow.png" alt="" />' />

set PostBackUrl property of Button control => https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.postbackurl(v=vs.110).aspx
the reason webforms always posting it 2 itself may be due to their __doPostBack script.

Related

Hitting Enter for Default Button in ASPX Doesn't Work but Mouse Does on IIS 6.2

I have an ASPX based solution that is running under .NET 4.8 and IIS 6.2. We have a login screen.
When a user enters their username and password, then hits enter or clicks enter, they should be logged in. The problem we are having is, if a user clicks the login button everything is fine but if they hit enter, the page seems to refresh but not postback.
Some history...We had this issue years ago when we were hosted under GoDaddy. There was some IIS setting that they changed at some point that broke our app and caused this. They wouldn't undo this as the setting (they wouldn't tell me what setting) would apply to others on the same IIS. We moved to a new host and now have our own IIS running on its on box. We have not had this issue for years and now recently it has cropped back up again. When I test this code locally under IIS Express via Visual Studio, we do not have the problem. When I publish to our server, the problem arises.
I am pulling my hair out on this one.
EDIT 2020-10-09 - Added markup
<form id="Form1" runat="server">
<div class="container" id="container" runat="server">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<p style="text-align: center;">
<img src="./images/logo160x300.png" />
</p>
<h2>
Sign In</h2>
<div id="errorPanel" runat="server" style="display: none;">
<asp:label ID="lblAuthenticationFailure" runat="server" Text="Login failed. Please check your username and password."
Visible="True" Font-Bold="True" ForeColor="#CC0000"></asp:label>
<br />
<br />
</div>
<label for="txtUser">
Email</label>
<asp:TextBox ID="txtUser" runat="server" placeholder="Email" type="email" class="form-control"
required autofocus AutoComplete="username"></asp:TextBox>
<br />
<label for="txtPassword">
Password</label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" placeholder="Password"
class="form-control" required AutoComplete="current-password"></asp:TextBox>
<div class="text-right small">
Forgot your password?</div>
<br />
<asp:Button ID="butLogin" runat="server" Text="Sign in" type="submit" class="btn btn-lg btn-primary btn-block" />
<br />
<div class="text-center">
New? Need an Account?<br />
</div>
<a class="btn btn-default btn-lg btn-block" href="createlogin.aspx" role="button">Create
an account</a>
<br />
</div>
</div>
</div>
</form>
In your form tag set the defaultButton to the login button.
<form id="form1" runat="server" defaultbutton="IdOfSubmitbutton">
You can set the default postback button on PageLoad by
Page.Form.DefaultButton = myButton;
Make sure you do a search. This has probably been answered.

When click on button it does not post back

I am using a button inside a form, and this from is inside another form. When button is inside the second form its calling directly page load event but not button click event. If I take the button outside the second form nothing will work neither its call page load method nor button click event.
<form id="form1" runat="server">
<form class="ak-form" method="post" action="#">
<ul class="agileits ">
<li class="agileits">
<input required="" id="txtCustMailId" runat="server" class="text-box-dark agileits " type="text" value="Enter Your Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Enter Your Email';}" name="email" /></li>
<li class="agileits">
<input required="" id="txtCustPass" runat="server" class="text-box-dark agileits " type="password" value="Your Password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Password';}" name="password" /></li>
</ul>
<div class="ak-btn-cont ak-btn-booking-cont login-btn">
<asp:Button runat="server" class="btn btn-primary agileits button2" CssClass="btn btn-info btnWidth100 btnFont" ID="btnCustLogin" ValidationGroup="CustLogin" Text="Login" OnClick="btnCustLogin_Click" />
<asp:Button runat="server" class="btn btn-primary agileits button2" CssClass="btn btn-info btnWidth100 btnFont" ID="Button2" Text="Forgot Password" OnClick="btnCustLogin_Click1" />
</div>
</form>
</form>
Consolidate the two forms into one form.
<form id="form1" class="ak-form" method="post" action="#" runat="server">
</form>
If you can't do this because #form1 is wrapping the entire page and in implementation the .ak-form is deeper in the documentation then try adding the runat="server" attribute to the second form element.

Asp.net - Stack Empty

In my asp.net webform project I'm trying to add asp:panel for search field. I need to use defaultbutton attribute.
<div class="input-group">
<asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch">
<input class="form-control" placeholder="Search" autocomplete="off" runat="server" onkeypress="searchclick('btnSearch',event);" id="txtSearch" />
<div class="input-group-btn">
<button class="btn btn-default" id="btnSearch" itemid="btnSeach" onserverclick="btnSearch_ServerClick" runat="server" type="submit"><i
class="glyphicon glyphicon-search"></i></button>
</div>
</asp:Panel>
</div>
When I try to do this I took error like.
error screen
If I just remove defaultbutton attribute the error is gone.

HTML5 required stops ASP:Button from working

I am trying to click on an ASP:Button with an onclick function. Every time I do that the HTML5 Required stops the click from occurring. I even tried to include an ASP:UpdatePanel but that does not work neither.
<form id="form1" name="theform" class="form-horizontal" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="fb_login" runat="server">
<asp:button CssClass="btn-facebook" ID="FacebookButton" Text="Login with Facebook" OnClick="FacebookButton_Click" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="container">
<div class="form-group">
<label for="FirstName">First Name</label>
<div>
<input type="text" tabindex="1" class="form-control" id="FirstName" required title="Enter First Name" runat="server" placeholder="First Name">
</div>
</div>
<div class="form-group">
<label for="LastName">Last Name</label>
<div>
<input type="text" tabindex="2" class="form-control" id="LastName" required title="Enter Last Name" runat="server" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary">Submit Information</button>
</div>
</div>
</div>
</form>
Remove the UpdatePanel and set UseSubmitBehavior="false" on FacebookButton:
<asp:button UseSubmitBehavior="false" CssClass="btn-facebook" ID="FacebookButton" Text="Login with Facebook" OnClick="FacebookButton_Click" runat="server" />

cant display inline in web forms app with bootstrap

I am customizing the account registration section of a new VS 2013 web application which comes with bootstrap css format. I am trying to build a form on a page and cannot get one section to display inline instead of block. Latest try is below.
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="ddlCountry" CssClass="col-md-2 control-label">Country</asp:Label>
<div class="col-md-10">
<asp:DropDownList runat="server" ID="ddlCountry" CssClass="form-control" Width="200" />
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="tbPostalCode" CssClass="col-md-2 control-label">Postal Code</asp:Label>
<div class="col-md-10-inline">
<asp:TextBox runat="server" ID="tbPostalCode" CssClass="form-control" Width="200" MaxLength="10" Height=" " />
<asp:RequiredFieldValidator runat="server" ControlToValidate="ddlCountry"
CssClass="text-danger" ErrorMessage="The country field is required." />
<asp:RequiredFieldValidator runat="server" ControlToValidate="tbPostalCode"
CssClass="text-danger" ErrorMessage="The postal code field is required." />
</div>
</div>
</div>
</div>
This is how everything I try to get it to display inline ends up looking like
I want the Postal Code label and text box to display on same line as Country. Normally an easy task but bootstrap clearing getting in the way
what i did to achieve this is wrote each form controls in a separate row. ie,
<form role="form">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="fname">First Name</label>
<input type="text" class="form-control" id="fname" placeholder="Enter email">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="lname">Last Name</label>
<input type="text" class="form-control" id="lname" placeholder="Enter Last Name">
</div>
</div>
</div>
</form>
In the above code, First Name and Last Name elements will be shown in a same line,
I don't know whether its right way or not but it worked for me.
check it here http://ezmotionq.com/registration

Resources