Very Simple For Developer

Very Simple For Developer

Page 1 of 1

2 Replies - 719 Views - Last Post: 06 January 2011 - 11:50 PM Rate Topic: -----

#1 Shahzad_Saifi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-January 11

Very Simple For Developer

Posted 06 January 2011 - 06:21 AM

I want to know how to pass values between pages in ASP.NET using c#
Is This A Good Question/Topic? 0
  • +

Replies To: Very Simple For Developer

#2 Tryparse  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 80
  • View blog
  • Posts: 193
  • Joined: 20-April 10

Re: Very Simple For Developer

Posted 06 January 2011 - 10:51 AM

Google "ASP.NET c# session variables"
Was This Post Helpful? 1
  • +
  • -

#3 Vishu Sukhdev  Icon User is offline

  • D.I.C Head

Reputation: 38
  • View blog
  • Posts: 150
  • Joined: 19-February 10

Re: Very Simple For Developer

Posted 06 January 2011 - 11:50 PM

Hi,
you can try this

First Page Search.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>

<!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>Search</title>
    
    <script runat="server" >
        
    public string SearchString
    {
        get { return txtSearch.Text; }
    }
    
    </script>
    
</head>

<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label
        id="lblSearch"
        Text="Search:"
        Runat="server" />
    <asp:TextBox
        id="txtSearch"
        Runat="server" />
    <asp:Button
        id="btnSearch"
        Text="Go!"
        PostBackUrl ="~/ButtonSearchResults.aspx" 
        Runat="server" />
    </div>
    </form>
</body>
</html>



Second Page ButtonSearchResults.aspx

<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath ="~/Search.aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    void Page_Load()
    {
        if (Page.PreviousPage != null)
        {
            lblSearch.Text = String.Format("Search For: {0}", PreviousPage.SearchString);
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <asp:Label
        id="lblSearch"
        Runat="server" />
    </div>
    </form>
</body>
</html>




Remember that we Import <%@ PreviousPageType VirtualPath ="~/Search.aspx" %> in ButtonSearchResults.aspx


or also click Here for vb example
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1