473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Syntax Challenged

I find myself Syntax Challenged.
An array resides on a MasterPage.
I want to use the values of the array on an aspx page which is a content
page of the MasterPage.
I can not find the syntax that works.

For a single value (non-array) the following will work.

On the MasterPage:
public String CompanyName
{
get { return (String) ViewState["companyName"]; }
set { ViewState["companyName"] = value; }
}
void Page_Init(Object sender, EventArgs e)
{
this.CompanyName = "JimBo";
}On the ContentPage:<%@ MasterType virtualpath="~/Master1.master" %>void
Page_Load(Object sender, EventArgs e)
{
Label1.Text = Master.CompanyName;
}I need the equivalent code for a array. Code examples would be
appreciated.Thanks,Jim
May 31 '06 #1
4 1105
public String[] MyArray
{
get { return (String[]) ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}


Jim McGivney wrote:
I find myself Syntax Challenged.
An array resides on a MasterPage.
I want to use the values of the array on an aspx page which is a content
page of the MasterPage.
I can not find the syntax that works.

For a single value (non-array) the following will work.

On the MasterPage:
public String CompanyName
{
get { return (String) ViewState["companyName"]; }
set { ViewState["companyName"] = value; }
}
void Page_Init(Object sender, EventArgs e)
{
this.CompanyName = "JimBo";
}On the ContentPage:<%@ MasterType virtualpath="~/Master1.master" %>void
Page_Load(Object sender, EventArgs e)
{
Label1.Text = Master.CompanyName;
}I need the equivalent code for a array. Code examples would be
appreciated.Thanks,Jim

Jun 1 '06 #2
Ray:
This generates an error:
public String[] MyArray
{
get { return (String[])ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}

protected void Button1_Click(object sender, EventArgs e)
{
MyArray[0] = "Zero";
Label1.Text = MyArray[0].ToString();
// Generates error: Object reference not set to an instance of an object.
}

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
public String[] MyArray
{
get { return (String[]) ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}


Jim McGivney wrote:
I find myself Syntax Challenged.
An array resides on a MasterPage.
I want to use the values of the array on an aspx page which is a content
page of the MasterPage.
I can not find the syntax that works.

For a single value (non-array) the following will work.

On the MasterPage:
public String CompanyName
{
get { return (String) ViewState["companyName"]; }
set { ViewState["companyName"] = value; }
}
void Page_Init(Object sender, EventArgs e)
{
this.CompanyName = "JimBo";
}On the ContentPage:<%@ MasterType virtualpath="~/Master1.master" %>void
Page_Load(Object sender, EventArgs e)
{
Label1.Text = Master.CompanyName;
}I need the equivalent code for a array. Code examples would be
appreciated.Thanks,Jim

Jun 1 '06 #3
I was just showing you how to create the property.

Where are you created the array to set it to the property.

Using:
String[] _a = new String[1] {"Hello"};

You can create the array and then set it to the property:

MyArray = _a;

Then:

MyArray[0] = "Zero" will work.

Jim McGivney wrote:
Ray:
This generates an error:
public String[] MyArray
{
get { return (String[])ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}

protected void Button1_Click(object sender, EventArgs e)
{
MyArray[0] = "Zero";
Label1.Text = MyArray[0].ToString();
// Generates error: Object reference not set to an instance of an object.
}

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
public String[] MyArray
{
get { return (String[]) ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}


Jim McGivney wrote:
I find myself Syntax Challenged.
An array resides on a MasterPage.
I want to use the values of the array on an aspx page which is a content
page of the MasterPage.
I can not find the syntax that works.

For a single value (non-array) the following will work.

On the MasterPage:
public String CompanyName
{
get { return (String) ViewState["companyName"]; }
set { ViewState["companyName"] = value; }
}
void Page_Init(Object sender, EventArgs e)
{
this.CompanyName = "JimBo";
}On the ContentPage:<%@ MasterType virtualpath="~/Master1.master" %>void
Page_Load(Object sender, EventArgs e)
{
Label1.Text = Master.CompanyName;
}I need the equivalent code for a array. Code examples would be
appreciated.Thanks,Jim


Jun 1 '06 #4
Thanks Ray, it worked.
Jim
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
I was just showing you how to create the property.

Where are you created the array to set it to the property.

Using:
String[] _a = new String[1] {"Hello"};

You can create the array and then set it to the property:

MyArray = _a;

Then:

MyArray[0] = "Zero" will work.

Jim McGivney wrote:
Ray:
This generates an error:
public String[] MyArray
{
get { return (String[])ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}

protected void Button1_Click(object sender, EventArgs e)
{
MyArray[0] = "Zero";
Label1.Text = MyArray[0].ToString();
// Generates error: Object reference not set to an instance of an object.
}

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
public String[] MyArray
{
get { return (String[]) ViewState["MyArray"]; }
set { ViewState["MyArray"] = value; }
}


Jim McGivney wrote:
I find myself Syntax Challenged.
An array resides on a MasterPage.
I want to use the values of the array on an aspx page which is a
content page of the MasterPage.
I can not find the syntax that works.

For a single value (non-array) the following will work.

On the MasterPage:
public String CompanyName
{
get { return (String) ViewState["companyName"]; }
set { ViewState["companyName"] = value; }
}
void Page_Init(Object sender, EventArgs e)
{
this.CompanyName = "JimBo";
}On the ContentPage:<%@ MasterType virtualpath="~/Master1.master"
%>void Page_Load(Object sender, EventArgs e)
{
Label1.Text = Master.CompanyName;
}I need the equivalent code for a array. Code examples would be
appreciated.Thanks,Jim


Jun 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
28
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice...
4
by: MLH | last post by:
I apologize in advance to forum readers noticing this somewhat redundant post. I fear that my Subject Heading was ill-chosen in earlier post I made on this topic. Am hoping that a clearer Subject...
2
by: Richard Lawson | last post by:
Every time developers try to connect to a Windows 2003, IIS 6.0 server they are challenged by NT. The directory is shared and they have full rights and can connect using Windows Explorer and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.