在另一页中获取值 [英] Fetch Values in another page

查看:51
本文介绍了在另一页中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sir / Ma''am



我在.aspx网站上工作,vb是默认语言。



在第一页名称为Default.aspx.vb我有两个文本框名称为

TextBox1

TextBox2

我想要将这些文本框的值重定向到

文本框在第二个页面名称中找到Default2.aspx。



我给出值1 default.aspx页面的textbox2中的TextBox1和afgh

和重定向后我在Default2.aspx页面的文本框1中发现值为1afgh

和default2的textbox 2仍然是空的。

而ans必须是





1 in Textbox1(Of Defalt 2)

afgh in Text Box2(Of Defalt 2)





我使用的代码为

url =Default2.aspx?name =&TextBox1.Text&mail =&TextBox2.Text

Sir/Ma''am

I am working in a .aspx site with vb as default language.

In first page name as Default.aspx.vb i have two textbox name as
TextBox1
TextBox2
I want to redirect the value of these Text box in to the
Textboxes find in second page name as Default2.aspx.

I give values 1 in the TextBox1 and afgh in the textbox2 of default.aspx page
and after redirecting i found value as 1afgh in the textbox 1 of Default2.aspx page
and textbox 2 of default2 remains empty.
while ans must be


1 in Textbox1(Of Defalt 2)
afgh in Text Box2 (Of Defalt 2)


I use the code as
url = "Default2.aspx?name=" & TextBox1.Text & " mail=" & TextBox2.Text

推荐答案

考虑使用会话



页数: Default.aspx.vb







Think About Using the Session

Page : Default.aspx.vb



Session("txtbox1") =  TextBox1.Text
Session("txtbox2") =  TextBox2.Text

Response.Redirect("Default2.aspx")







页面: Default2.aspx.vb






Page : Default2.aspx.vb

TextBox1.Text=Session("txtbox1")
TextBox2.Text=Session("txtbox2")


这些链接可以帮助你 -

http://msdn.microsoft.com/en-us/library/6c3yckfw%28v=vs.100%29.aspx [ ^ ]

将页面值传输到另一页 [ ^ ]

http://ramanisandeep.net/2008/11/21/传递值从一页到另一页 - aspnet / [ ^ ]
These links should help you out -
http://msdn.microsoft.com/en-us/library/6c3yckfw%28v=vs.100%29.aspx[^]
Transferring page values to another page[^]
http://ramanisandeep.net/2008/11/21/passing-values-from-one-page-to-another-page-aspnet/[^]


请尝试以下示例代码 -



default.aspx.vb

try these sample code below-

default.aspx.vb
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Partial Class Default1
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)

	End Sub
	
	Protected Sub Button1_Click(sender As Object, e As EventArgs)
		Dim c1 As New HttpCookie("click")
		Dim c2 As New HttpCookie("click1")

		c1.Value = TextBox1.Text
		c2.Value = TextBox2.Text
		c1.Expires = DateTime.Now.AddHours(1) ''cookiee validity of 1 hrs
		c2.Expires = DateTime.Now.AddHours(1) ''cookiee validity of 1 hrs
		Response.Cookies.Add(c1)
		Response.Cookies.Add(c2)
		Response.Redirect("Default2.aspx")
	End Sub





default2.aspx.vb





default2.aspx.vb

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Partial Class Default2
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)

		TextBox1.Text = Request.Cookies("Click").Value
		TextBox2.Text = Request.Cookies("Click1").Value
	End Sub

End Class





default.aspx





default.aspx

<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="Default" %>

<!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">
    <title>Data Enter</title>
    <style type="text/css">
        .style1
        {
            width: 275px;
            border-style: solid;
            border-width: 1px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <table cellpadding="2" class="style1">
            <tr>
                <td>
                    first name</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" Width="142px"></asp:TextBox>
                </td>
            </tr>
             <tr>
                <td>
                  last name  </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" Width="142px"></asp:TextBox>
                </td>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
                </td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>





default2.aspx





default2.aspx

<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!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">
    <title>Cookie Show</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        <br />
        <br />

        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

    </div>
    </form>
</body>
</html>





*代码从c#转换为VB.net。并使用cookiee传递值。



我希望它有所帮助。



*codes are converted from c# to VB.net. and used cookiee to pass values.

I hope it helped.


这篇关于在另一页中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆