mimic HTML form behaviour in asp.net page

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
5/5/2012 6:59:55 PM
Gravatar
Total Posts 20
Dale Innis, What was, What is and What will be is all in the hands of God, but an application is in the hands of the developer, Lord Help us!

mimic HTML form behaviour in asp.net page

Hi guys I am rebuiding the following form in asp.net

 

<form name="Form1" id="Form1" action="http://98.141.202.213/ccweb/login.aspx" method="post">
<input type ="hidden" value="1" name="Flag"/>
<div class="login-field">

<label>Account No.</label>
<input name="AccNo" id="AccNo" type="text" />
<br />
<label>User Id</label>
<input name="UserID" id="UserID" type="text" />
<label>Password</label>
<input id="Passwd" name="Passwd"" type="password" />
</div>
<div class="login-button">
<label>
<input type="submit" name="button" id="button" value="" />
</label>

</div> </form>

 

 

I have built a custom control that works nice up and including the submit button lol....

 

private string PostUrl = "http://98.175.26.137/ccweb/Login.aspx"; // you shouldn't need to change this

private void LoadSettings()
{
Title1.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
this.Description = this.ModuleConfiguration.FeatureName;
}

btnLoginButton.PostBackUrl = PostUrl;
}

<asp:Panel ID="Login" runat="server" CssClass="modulecontent">
<p></p>
Account No: <asp:TextBox ID="AccNo" runat="server" name="AccNo"></asp:TextBox>
User ID: <asp:TextBox ID="UserID" runat="server" name="UserID"></asp:TextBox>
Password: &nbsp <asp:TextBox id="Passwd" TextMode="password" runat="server" name="Passwd"/>
<asp:Button ID="btnLoginButton" runat="server" Text="Submit" />
</asp:Panel>

It links to the page nicely and pulls it up but doesn't pass the three values to the corresponding boxes which using the html would long the person in.

 

Any help to get the behviour of the control to finish working would be really appreciated.

5/6/2012 9:12:54 AM
Gravatar
Total Posts 18439

Re: mimic HTML form behaviour in asp.net page

There can be one and only one form on the page in ASP.NET webforms and that form already exists in layout.master so you cannot put one in your control and don't need one in your control to do postback to the same page. If you need to postback to a different page you still do not need an additional form, you just set the postbackurl property on your button. Use ASP.NET WebCotrols like <asp:TextBox and <asp:Button instead of raw html  inputs.

See also:

Hope that helps,

Joe

5/6/2012 5:37:48 PM
Gravatar
Total Posts 20
Dale Innis, What was, What is and What will be is all in the hands of God, but an application is in the hands of the developer, Lord Help us!

Re: mimic HTML form behaviour in asp.net page

Yup that is what I am copying and trying to change, but my understanding of asp is so new... I don't want to really have another form or use html, I am completely fine with the asp  what is not working though is it doesn't post back all the fields like the html did... just seems to go to the page and doesn't log in and go to the next page.  usually this passes all the account,user and password to that login.aspx which then logs you in. but the asp.net doesn't seem to do that.       


 <%@ Control Language="C#" ClassName="LoginUserControl.ascx" Inherits="mojoPortal.Web.SiteModuleControl" %>

<%@ Import Namespace="mojoPortal.Business" %>
<%@ Import Namespace="mojoPortal.Business.WebHelpers" %>
<%@ Import Namespace="mojoPortal.Web.Framework" %>
<%@ Import Namespace="mojoPortal.Web.Controls" %>
<%@ Import Namespace="mojoPortal.Web.Editor" %>
<%@ Import Namespace="mojoPortal.Net" %>

<script runat="server">
// Author: Joe Audette
// Created: 2010-12-14
// Last Modified: 2010-12-14

protected string HostedButtonId = "XXXXXXXXXX"; // your PalPal Generated value for hosted_button_id
private string buttonImageUrl = "https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"; // or donate button https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif
private string payPalPostUrl = "http://98.175.26.137/ccweb/Login.aspx"; // you shouldn't need to change this

protected void Page_Load(object sender, EventArgs e)
{
LoadSettings();
}

private void LoadSettings()
{
Title1.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
this.Description = this.ModuleConfiguration.FeatureName;
}

}

</script>

<portal:mojoPanel ID="mp1" runat="server" ArtisteerCssClass="art-Post" RenderArtisteerBlockContentDivs="true">
<mp:CornerRounderTop id="ctop1" runat="server" />
<asp:Panel ID="pnlWrapper" runat="server" CssClass="art-Post-inner panelwrapper linksmodule">
<portal:ModuleTitleControl id="Title1" runat="server" />
<portal:mojoPanel ID="MojoPanel1" runat="server" ArtisteerCssClass="art-PostContent">
<asp:Panel ID="Login" runat="server" CssClass="modulecontent">
<p></p>
Account No: <asp:TextBox ID="AccNo" runat="server" name="AccNo" ></asp:TextBox>
User ID: <asp:TextBox ID="UserID" runat="server" name="UserID" ></asp:TextBox>
Password: &nbsp <asp:TextBox id="Passwd" TextMode="password" runat="server" name="Passwd" />
<asp:Button ID="btnLoginButton" runat="server" Text="Submit" PostBackUrl = "http://98.175.26.137/ccweb/Login.aspx" />
</asp:Panel>
<div class="modulefooter"></div>
</portal:mojoPanel>
<div class="cleared"></div>
</asp:Panel>
<mp:CornerRounderBottom id="cbottom1" runat="server" />
</portal:mojoPanel>


I am still learning what i can and cannot remove/change so this is just a work in progress but this is what i have so far.

5/7/2012 7:39:34 AM
Gravatar
Total Posts 18439

Re: mimic HTML form behaviour in asp.net page

If you are posting to a different page then it probably is best to use plain html inputs for the textboxes since you won't be able to get to them on the other page the same way you would if posting back on the current page. You'll have to get the posted from variables using Request.Params. You will still need to use <asp:Button.

If the other page is in the same site you would set the button postbackurl like: "~/Login.aspx" assuming that the page you are posting from is running under /ccweb/

But you could also postback to the current page and then redirect out of postback on successful login, then you can get to the values of the textboxes more easily using the server ids

string acctNo = AccNo.Text;

also posting to a different page makes it hard to handle if the login fails.

Myself if I was going to make a custom login I would not make it a control hosted by a CMS page, I would make a standalone page. You can make our Sign In link point to your custom page by adding this in user.config:

<add key="LoginPageRelativeUrl" value="/Login.aspx"/> assuming that page exists in the root of your site

Then you have full control over the page and can just postback directly to the same page like our built in login page does.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.