Link to home
Start Free TrialLog in
Avatar of teddysetiawan
teddysetiawan

asked on

REQUEST.FORM QUESTION ASP.NET

Hi Im new in ASP.NET , I have problem validating with request.form syntax , it seem that if i send it to another page , all variable gone , I try to catch it using request.form.haskeys ... and return false


this is my code....

TEST.aspx....

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="WebApplication1.test"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>test</title>
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <asp:TextBox id="txtname" style="Z-INDEX: 102; LEFT: 260px; POSITION: absolute; TOP: 65px" runat="server"></asp:TextBox>
                  <asp:TextBox id="txtaddress" style="Z-INDEX: 101; LEFT: 260px; POSITION: absolute; TOP: 92px" runat="server"></asp:TextBox>
                  <asp:Label id="Label1" style="Z-INDEX: 103; LEFT: 202px; POSITION: absolute; TOP: 73px" runat="server">Name</asp:Label>
                  <asp:Label id="Label2" style="Z-INDEX: 104; LEFT: 201px; POSITION: absolute; TOP: 97px" runat="server">Address</asp:Label>
                  <asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 369px; POSITION: absolute; TOP: 119px" runat="server" Text="Send"></asp:Button>
            </form>
      </body>
</HTML>


TEST.ASPX.VB   (code behind)
Public Class test
    Inherits System.Web.UI.Page
    Protected WithEvents txtaddress As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtname As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Redirect("result.aspx")
    End Sub
End Class


Another page for retrieving value........

RESULT.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="result.aspx.vb" Inherits="WebApplication1.WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>WebForm2</title>
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 145px; POSITION: absolute; TOP: 72px" runat="server">Your Name</asp:Label>
                  <asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 146px; POSITION: absolute; TOP: 98px" runat="server">Your Address</asp:Label>
                  <asp:Label id="lblname" style="Z-INDEX: 103; LEFT: 254px; POSITION: absolute; TOP: 72px" runat="server"></asp:Label>
                  <asp:Label id="lbladdress" style="Z-INDEX: 104; LEFT: 255px; POSITION: absolute; TOP: 95px" runat="server"></asp:Label>
            </form>
      </body>
</HTML>


Code Behind

Result.aspx.vb


Public Class WebForm2
    Inherits System.Web.UI.Page
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents lblname As System.Web.UI.WebControls.Label
    Protected WithEvents lbladdress As System.Web.UI.WebControls.Label
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblname.Text = Request.Form("txtname")
        lbladdress.Text = Request.Form("txtaddress")
    End Sub


End Class







ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
teddysetiawan,
why Gred B? I'd include explanations and sample coding. It's should be 'A' because i answer your answer completely.
Please Refer https://www.experts-exchange.com/help/closing.jsp#7

Regards
x_com
Avatar of teddysetiawan
teddysetiawan

ASKER

I'm sorry , I do not understand the grading policy here in EE ,
Thanks for the help x_com , but  how can I change the grade  ?
teddysetiawan ,
It's ok. welcome to EE as well.
Admin will handle it. Next time, if you had questions about EE, you can always post the helps at CS area, admin will handle all the request from EE members :
http://oldlook.experts-exchange.com/Community_Support

Regards
x_com