0

Hy all,

I am sure its very simple thing and I am not just getting it, I am trying to send textbox value from one page to another and its keep giving me an error, basicaly its not finding the class I created in previous page. My web pages are inherited from Master pages so that might be a problem. My code on First page is as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Members_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int chid;
        chid = Convert.ToInt32(DetailsView1.Rows[0].Cells[1].Text);
        TextBox1.Text = chid.ToString();
    }
    public string meetingID
    {
        get
        {
            return Convert.ToString(TextBox1.Text);
        }

    }

My Code on Target page is as follows.
Html code

<%@ Page Title="" Language="C#" MasterPageFile="~/Members/MasterPage.master" AutoEventWireup="true" CodeFile="invitemem.aspx.cs" Inherits="Members_Default" %>
<%@ PreviousPageType VirtualPath="~/Members/Members.aspx"%>

c# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Members_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       Pre_meetingid.Text = PreviousPage.meetingID; //Here I am getting Error on meetingID as ASP.net doesnt contain definition of meetingID
        //if (PreviousPage != null)
       // {
        //  ContentPlaceHolder cp = Page.PreviousPage.Form.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
         // if (cp != null)
         // {
          //    TextBox tb = cp.FindControl("TextBox1") as TextBox;
           //   if (tb != null)
            //  {
            //      Pre_meetingid.Text = tb.Text;
            //  }
          //}
      //  }
  }
}

I have also tried second way which is being commented and the returns no value.

Any Idea where I am going wrong or do we need any other assembly apart from Html code one?

Thanks in advance.

Gibz

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by giahmed
0

I am not the best to answer this but I don't think you can call a method from another page. But you can get the value from the textbox from a previous. So if the value you need is in TextBox1 on the previous page you can try this.

TextBox myBox = (TextBox)PreviousPage.FindControl("TextBox1");
 if (myBox.Text != null)
    Label2.Text = myBox.Text;
 else
    Label2.Text = "Nothing was in textbox";
0

>I am trying to send textbox value from one page to another and its keep giving me an error

Query string

string val=TextBox1.Text;

Response.Redirect("page2.aspx?val=" + val);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.