login form to call cobol program to validate

I am writing a web application.

I have a standard login form to enter user number and password. I then need to pass this to a cobol program to validate before returning and continuing.

The login form is called from the Site.Master

Parents
  • <fieldset>
    <asp:Label ID="Label2" runat="server" Text="Usuário: "></asp:Label>
    <asp:TextBox ID="txUsuario" runat="server" Width="80%" CssClass="textbox"></asp:TextBox>
    </fieldset>
    <fieldset>
    <asp:Label ID="Label3" runat="server" Text="Senha: "></asp:Label>
    <asp:TextBox ID="txSenha" runat="server" Width="80%" CssClass="textbox" TextMode="Password"></asp:TextBox>
    </fieldset>
    <fieldset>
    <asp:Button ID="btLogar" runat="server" Text="Ok" Width="100%" CssClass="ButtonStyle" align="center" OnClick="btLogar_Click" />
    </fieldset>

     

    method-id btLogar_Click protected.
    procedure division using by value sender as object e as type System.EventArgs.

    move txUsuario::Text    to user-cad
    move txSenha::Text      to wpass-cad
    perform verifica-senha-gravada

    exit method.

    verifica-senha-gravada.

    open input usuario

    read usuario key is user-cad invalid key
               move "Usuário ou senha invalidos..." to Lnk-Mensagem
    not invalid key

    if  pass-cad = wpass-cad

    move "OK"    to Lnk-Mensagem

    end-if
    end-read
    close usuario

    Veja se te ajuda

  • Morning.

    Thank you for this.

    move UserName::Text to loginName.
    move Password::Text to loginPassword.

    When I move the text fields I get errors

    COBCH1710  '~~Account.login' has no member with name 'UserName'

    COBCH1710  '~~Account.login' has no member with name 'Password'

  • Are UserName and Password the actual names of the textbox controls on the login form?

    I believe that Password is a reserved word in COBOL so you should use a different name or preface it with "#".

    Can you please post your html code or the code in the code-behind .cbl program so we can take a look?

  • Hi Chris

    I got this from the Micro Focus samples so it works perfectly

    <%@ Page Title="Log In" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Login.aspx.cbl" Inherits="SalarySurveyWebApplication.Account.Login" %>

    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <p>
    Please enter your username and password.
    <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
    </p>
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
    <LayoutTemplate>
    <span class="failureNotification">
    <asp:Literal ID="FailureText" runat="server"></asp:Literal>
    </span>
    <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
    ValidationGroup="LoginUserValidationGroup"/>
    <div class="accountInfo">
    <fieldset class="login">
    <legend>Account Information</legend>
    <p>
    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
    <asp:TextBox ID="UserName" runat="server" CssClass="textbox"></asp:TextBox>
    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
    CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
    ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
    </p>
    <p>
    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
    <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password" ></asp:TextBox>
    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
    CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
    ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
    </p>
    <p>
    <asp:CheckBox ID="RememberMe" runat="server"/>
    <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
    </p>
    </fieldset>
    <p class="submitButton">
    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" OnClick="LoginButton_Click"/>
    </p>
    </div>
    </LayoutTemplate>
    </asp:Login>
    </asp:Content>

    LOGIN.ASPX.CBL

    class-id SalarySurveyWebApplication.Account.Login is partial
    inherits type System.Web.UI.Page public.

    working-storage section.
    01 call-menu type SurveyWrapper.menu .

    method-id Page_Load protected.
    local-storage section.
    01 returnUrl string.
    01 encodedUrl string.

    procedure division using by value sender as object by value e as type EventArgs.
    set returnUrl to super::Request::QueryString::Item("ReturnUrl")
    set encodedUrl to type HttpUtility::UrlEncode(returnUrl)
    set RegisterHyperLink::NavigateUrl to String::Concat( "Register.aspx?ReturnUrl=" encodedUrl)
    goback.
    end method.

    This is where it starts to go pear shaped.

    method-id LoginButton_Click protected.
    working-storage section.
    01 logininfo type SalarySurveyWebApplication.Account.Login.
    01 loginName pic 99.
    01 loginPassword pic x(6).
    procedure division using by value sender as object e as type System.EventArgs.

    move logininfo::UserName::Text to loginName.
    move Password::Text to loginPassword.

    set logininfo to new Login()

    * set logininfo to new SalarySurveyWebApplication.Account.Login (self::UserName::Text, self::Password::Text)

    *
    * if (loginform::ShowDialog) =type DialogResult::OK)
    * set label1::Text to "User=" & loginform::loginName & " pass=" &
    * loginform::loginpassword
    * else
    * set LoginButton::Text to "User pressed Cancel"
    * end-if
    * end method.

    * set self::DialogResult to type DialogResult::OK
    * set self::loginName to UserName::Text
    * set self::loginPassword to PasswordLabel::Text
    * invoke self::Close.
    *
    end method.

    I know it looks like a dog's breakfast but I have tried so many things.

    Basically I don't know how to make the two talk to each other. That could propably solve my other problem which is the gridview. Once I have selected a record from the gridview I need to sent that infomation to a different .aspx page.

    EMPLIST.aspx

    <%@ Page Title="" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EmpList.aspx.cbl" Inherits="SalarySurveyWebApplication.EmpList" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
    Width="400px" CssClass="table table-responsive table-striped"
    AllowSorting="True" OnRowEditing="GridView1_RowEditing"
    DataSourceID="SqlDataSource1" DataKeyNames="cce_rec_no">
    <EmptyDataRowStyle CssClass="texto_grid" Wrap="False" />
    <FooterStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" CssClass="texto_site" />
    <EditRowStyle BackColor="#999999" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="true" ForeColor="White" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" Font-Size="10pt" Wrap="False" />
    <PagerSettings Mode="NextPrevious"
    Position="Bottom"
    PageButtonCount="10"
    NextPageText="Próximo"
    PreviousPageText="Anterior"
    PreviousPageImageUrl="~/Images/Gnome-Go-Previous-32.png"
    NextPageImageUrl="~/Images/Gnome-Go-Next-32.png" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" Wrap="False" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
    <asp:BoundField DataField="cce_rec_no" HeaderText="cce_rec_no" SortExpression="cce_rec_no" ReadOnly="True" InsertVisible="True" ShowHeader="False" Visible="False" />
    <asp:BoundField DataField="cce_co_no" HeaderText="Company" SortExpression="cce_co_no" />
    <asp:BoundField DataField="cce_emp_no" HeaderText="Employee No" SortExpression="cce_emp_no" />
    <asp:BoundField DataField="cce_inits" HeaderText="Inits" SortExpression="cce_inits" />
    <asp:BoundField DataField="cce_surname" HeaderText="Surname" SortExpression="cce_surname" />
    </Columns>
    </asp:GridView>
    <asp:TextBox ID= "TxSelAba" runat="server" value="tabPage1" Text="AbaAtual" type="hidden" </asp:TextBox>


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=QASQL\SQL2017;Initial Catalog=CSS;User ID=shirley;Password=Password1" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [CsfCoEmp]"></asp:SqlDataSource>
    </asp:Content>

    EMPLIST.aspx.CBL

    class-id SalarySurveyWebApplication.EmpList is partial
    inherits type System.Web.UI.Page public.

    working-storage section.
    01 indx pic 9(3).
    method-id Page_Load protected.
    local-storage section.
    procedure division using by value param-sender as object
    param-e as type System.EventArgs.

    * GridView1.HeaderRow::TableSection = TableRowSection::TableHeader.

    goback.
    end method.

    method-id GridView1_RowCreated protected.
    procedure division using by value sender as object e as type System.Web.UI.WebControls.GridViewRowEventArgs.

    set indx = GridView1::SelectedIndex

    if (e::Row::RowType = type DataControlRowType::DataRow)
    set e::Row::Attributes::Item("onmouseover") to "this.style.cursor='pointer';this.style.textDecoration='underline';"
    set e::Row::Attributes::Item("onmouseout") to "this.style.textDecoration='none';"
    set e::Row::Attributes::Item("onclick") to self::ClientScript::GetPostBackClientHyperlink(self::GridView1, "Select$" & e::Row::RowIndex, false)
    end-if

    * EnableEventValidation="false"
    end method.


    method-id GridView1_RowEditing protected.
    procedure division using by value sender as object e as type System.Web.UI.WebControls.GridViewEditEventArgs.
    end method.


    method-id GridView1_SelectedIndexChanged protected.
    procedure division using by value sender as object e as type System.EventArgs.

    if self::GridView1::SelectedIndex = 1
    continue
    end-if

    end method.

    end class.

    Once a record has been selected I want it to be sent a totally different  .aspx page where I can edit the record.

    <%@ Page Title="MainContent" AutoEventWireup="true"
    CodeBehind="WebFormCSE110.aspx.cbl" Inherits="SalarySurveyWebApplication.WebFormCSE110" MasterPageFile="Site.Master" %>

    <%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    </head>
    <body>
    </body>--%>

    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h1 style="color: #FFFFFF; position: absolute; font-family: Verdana; font-size: large; font-style: italic; top: 197px; left: 272px;" >
    AMEND EMPLOYEE DETAILS


    </h1>
    <div class="dropdown open">
    <button class ="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
    data-toggle="dropdown" aria-haspopup="true aria-expanded="true" >Select
    <span class="caret"></span></button>
    <div class="dropdown-menu" >
    <a class="dropdown-item" href="EmpList.aspx">List</a>
    <a class="dropdown-item" href="#">Info</a>
    <a class="dropdown-item" href="#">Change</a>
    <%-- <div class="dropdown-divider"</div>--%>
    <a class="dropdown-item" href="#">Quit</a>

    </div>
    </div>
    <div>
    <br />
    $('.dropdown-item').click(function() {
    console.log( $(this).text() );
    });
    <div class="container">
    <div class ="row">
    <div class="col-xs"></div>
    <div class="col-sm"></div>
    </div>

    </div>
    <script>
    $(document).ready(function () {
    var x = $(event.relatedTarget).text();
    alert("you chose me: ") x);
    });
    });
    </script>
    <div class="table-responsive">
    <table class="table">
    <tr>
    <td>
    <asp:Label ID="lbCoEmp" runat="server" Text="Co/Employee" ></asp:Label>
    <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" style="margin-bottom: 6px"></asp:TextBox>
    <asp:Label ID="lbSlash" runat="server" Text="/" ></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextBox3" runat="server" CssClass="auto-style10"></asp:TextBox>
    <asp:TextBox ID="TextBox4" runat="server" CssClass="auto-style11"></asp:TextBox>
    </td>
    </tr>
    </table>
    </div>
    <div class="table-responsive">
    <table class="table">
    <tr>
    <td>
    <asp:Label ID="lbJobCode" runat="server" Text="Job Code" style="width: 115px; position: absolute; left: 241px; top: 342px"></asp:Label>
    </td>
    </tr>
    <tr>
    <td>
    <asp:Label ID="lbGroup" runat="server" Text="Group Specific" CssClass="auto-style3" style="width: 147px; height: 17px; position: absolute; left: 236px; top: 373px" ></asp:Label>

    </td>
    </tr>
    <tr>
    <td>
    <asp:Label ID="lbLocation" runat="server" Text="Location" CssClass="auto-style1" style="width: 49px; height: 17px; position: absolute; left: 249px; top: 392px" ></asp:Label>
    </td>
    </tr>
    <tr>
    <td>
    <asp:Label ID="lbProvince" runat="server" Text="Province" CssClass="auto-style1" style="width: 49px; height: 17px; position: absolute; left: 245px; top: 415px"></asp:Label>
    </td>
    </tr>
    <br />
    <br />
    <br />
    <br />
    </table>
    </div>
    </div>
    </asp:Content>

    Thank you so much in advance

    Shirley

  • Eu deixei um demo.zip na sua outra pergunta você viu? Nele tem 3 formas de comunicação entre formulários aspx.

    I left a demo.zip on your other question did you see? In it there are 3 forms of communication between aspx forms.

    Summing up:

    Session: set txUserName :: Text to Session ["SessionUserName"]

                      or/and

                      set Session["SessionUserName"] to txUserName::Text

    External: 01 wUserEX pic x (030) external.

                      set wUserEX to txUserName::Text

    Visible: <asp: TextBox ID = "txUserName" runat = "server" CssClass = "form-control" Visible = "False"> </ asp: TextBox>

    or

    <asp: TextBox ID = "txUserName" runat = "server" CssClass = "form-control" Visible = "True"> </ asp: TextBox>

     

    Good luck!

  • Hi there

    I have looked at your Demo. Thank you very much.

    I have a Default.aspx and a Default.aspx.cbl and these communicate perfectly. However I have a Login.aspx and a Login.aspx.cbl and when the aspx.cbl tries to access a field from the .aspx   set user-no to UserName::Text

    I get a COBCH1710: 'type SalarySurveyWebApplication.Account.Login' has no member with name 'UserName'

     

  • Thank you.

    From where did you get this particular sample? Can you provide a link please?

    Can you also post the contents of the code-behind file named Login.aspx.designer.cbl?

    There is a known bug in the current product version whereby the Web Designer doesn't always save new controls to the code-behind file and therefore they cannot be found when referenced. I would like to see if this is the problem you are experiencing.

    Are you modifying the actual sample or did you create a copy of it somehow?

    The best method of passing data between web pages would probably be to store the data as an object in the Session object. This object is persistant across roundtrips between the browser and the server. So prior to redirecting to the new page you can do something like:

    declare myobj as string = "TEST"   *> This can be any object such as your gridrow or a dataset

    *> This code stores the object into the Session object and gives it the name TESTVAR
    set Session["TESTVAR"] to myobj

    In your new page you can then retrieve the session object so that you can load it or bind it to the new control on the new page.

    declare myobj as string
    set myobj to Session["TESTVAR"]

    I would highly recommend that you read up on the ASP.NET programming model from Microsoft in order to understand the flow of these applications and session management. It can be a complex topic that would probably be difficult to learn by just looking at random COBOL examples demonstrating very simple tasks.

     

  • Hi Chris

    This is the link for the turorial I followed:

    /cobol/visualcobol/w/wikiid-16/19781/creating-web-applications-using-visual-cobol-and-asp-net

    I created a new application following this. Several actually!!

    This is the code behind Login.aspx.designer.cbl

    $set sourceformat(variable)

    *> Namespace: SalarySurveyWebApplication.Account

    class-id SalarySurveyWebApplication.Account.Login is partial.

    working-storage section.
    *>> <summary>
    *>> RegisterHyperLink control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 RegisterHyperLink type System.Web.UI.WebControls.HyperLink protected.
    *>> <summary>
    *>> LoginUser control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 LoginUser type System.Web.UI.WebControls.Login protected.
    *>> <summary>
    *>> SqlDataSource1 control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 SqlDataSource1 type System.Web.UI.WebControls.SqlDataSource protected.

    end class.

    I will try your methods and let you know how i get on.

    I have gone through so many tutorials but have still not grasped the whole picture so I will definitely go through the one you suggested.

    Many thanks

    Shirley

Reply
  • Hi Chris

    This is the link for the turorial I followed:

    /cobol/visualcobol/w/wikiid-16/19781/creating-web-applications-using-visual-cobol-and-asp-net

    I created a new application following this. Several actually!!

    This is the code behind Login.aspx.designer.cbl

    $set sourceformat(variable)

    *> Namespace: SalarySurveyWebApplication.Account

    class-id SalarySurveyWebApplication.Account.Login is partial.

    working-storage section.
    *>> <summary>
    *>> RegisterHyperLink control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 RegisterHyperLink type System.Web.UI.WebControls.HyperLink protected.
    *>> <summary>
    *>> LoginUser control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 LoginUser type System.Web.UI.WebControls.Login protected.
    *>> <summary>
    *>> SqlDataSource1 control.
    *>> </summary>
    *>> <remarks>
    *>> Auto-generated field.
    *>> To modify move field declaration from designer file to code-behind file.
    *>> </remarks>
    01 SqlDataSource1 type System.Web.UI.WebControls.SqlDataSource protected.

    end class.

    I will try your methods and let you know how i get on.

    I have gone through so many tutorials but have still not grasped the whole picture so I will definitely go through the one you suggested.

    Many thanks

    Shirley

Children