Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Saturday, March 24, 2012

the difference between string.Empty and null

greetings, i have some questions below, what are the differences between
private string _strVal = string.Empty; and _strVal = null;
does the string.Empty; allocate memory for it? how about _strVal = ""
thanks for enlightening me on this.string.Empty points to one string that equal "". due to literal pooling,
there is only one copy per assembly for "". null is a different value, and
takes no gc memory.
"Asha" <Asha@.discussions.microsoft.com> wrote in message
news:5AD99FFB-A480-4951-9F7D-E7DCBFE34453@.microsoft.com...
> greetings, i have some questions below, what are the differences between
> private string _strVal = string.Empty; and _strVal = null;
> does the string.Empty; allocate memory for it? how about _strVal = ""
> thanks for enlightening me on this.
To expand on Bruce's comment:
String.Empty is a valid instance of the string class, you can invoke
the Length property (and get back a value of 0). A null reference does
not refer to a valid object.
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 1 Nov 2004 17:09:01 -0800, "Asha"
<Asha@.discussions.microsoft.com> wrote:

>greetings, i have some questions below, what are the differences between
>private string _strVal = string.Empty; and _strVal = null;
>does the string.Empty; allocate memory for it? how about _strVal = ""
>thanks for enlightening me on this.
To expand on Scott's comment:
A string is actually an array of char. The array is terminated with a null
zero character (ASCII 0 or \0). The null zero does not count when referring
to the length of the string. It is simply the terminator character for the
array. A null string is a variable that is not initialized and points to
null. An empty string is a variable that points to an array with only a null
zero in it.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:8n1eo052sbblhhqq4ao03tdaske5r869n5@.
4ax.com...
> To expand on Bruce's comment:
> String.Empty is a valid instance of the string class, you can invoke
> the Length property (and get back a value of 0). A null reference does
> not refer to a valid object.
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Mon, 1 Nov 2004 17:09:01 -0800, "Asha"
> <Asha@.discussions.microsoft.com> wrote:
>
>

the difference between string.Empty and null

greetings, i have some questions below, what are the differences between

private string _strVal = string.Empty; and _strVal = null;

does the string.Empty; allocate memory for it? how about _strVal = ""

thanks for enlightening me on this.string.Empty points to one string that equal "". due to literal pooling,
there is only one copy per assembly for "". null is a different value, and
takes no gc memory.

"Asha" <Asha@.discussions.microsoft.com> wrote in message
news:5AD99FFB-A480-4951-9F7D-E7DCBFE34453@.microsoft.com...
> greetings, i have some questions below, what are the differences between
> private string _strVal = string.Empty; and _strVal = null;
> does the string.Empty; allocate memory for it? how about _strVal = ""
> thanks for enlightening me on this.
To expand on Bruce's comment:

String.Empty is a valid instance of the string class, you can invoke
the Length property (and get back a value of 0). A null reference does
not refer to a valid object.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 1 Nov 2004 17:09:01 -0800, "Asha"
<Asha@.discussions.microsoft.com> wrote:

>greetings, i have some questions below, what are the differences between
>private string _strVal = string.Empty; and _strVal = null;
>does the string.Empty; allocate memory for it? how about _strVal = ""
>thanks for enlightening me on this.
To expand on Scott's comment:

A string is actually an array of char. The array is terminated with a null
zero character (ASCII 0 or \0). The null zero does not count when referring
to the length of the string. It is simply the terminator character for the
array. A null string is a variable that is not initialized and points to
null. An empty string is a variable that points to an array with only a null
zero in it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:8n1eo052sbblhhqq4ao03tdaske5r869n5@.4ax.com...
> To expand on Bruce's comment:
> String.Empty is a valid instance of the string class, you can invoke
> the Length property (and get back a value of 0). A null reference does
> not refer to a valid object.
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Mon, 1 Nov 2004 17:09:01 -0800, "Asha"
> <Asha@.discussions.microsoft.com> wrote:
> >greetings, i have some questions below, what are the differences between
> >private string _strVal = string.Empty; and _strVal = null;
> >does the string.Empty; allocate memory for it? how about _strVal = ""
> >thanks for enlightening me on this.

Thursday, March 22, 2012

The exact definitions

hi all,

is there any source where i can find the exact definitions of various topic as like below:

1. Namespaces
2. class
3. obejects
4. .net framework
5. .net class library

etc. i need definitons of these types of many topics in such a way that i can just say and understand in brief. and you can say i have to tell someone( may be interviewer, any friend or the other)


pls help

thank you.


www.whatis.com


kaushalparik27:

www.whatis.com

thanks a lot. that's i was looking.


thanks again.


jitendra.dada:

kaushalparik27:

www.whatis.com

thanks a lot. that's i was looking.


thanks again.

pleasure to helps you.. and dont forget to mark the post as resolved for the sake of future readers. thanks.

The first intem in a DropDownList is vanishing!

The first intem in a DropDownList is vanishing!

My code to load a DropDownList is shown below. Yet when I load the
page after a postback there is no zeroth item present.

lstManager.Items.Clear();

lstManager.DataSource = _dsData.Tables["manager"].DefaultView;
lstManager.DataValueField = "ManagerID";
lstManager.DataTextField = "Name";
lstManager.DataBind();

lstManager.Items.Insert(0, new ListItem("none", "0"));

There's nothing special about the control definition:

<asp:DropDownList ID="lstManager" runat="server" Height="20px"
Width="250px" />

What's going on here?

This was the old code I replaced. Why does the old code (below) work
and why is my new code (above) broke?

lstManager.Items.Clear();

ListItem li = new ListItem("none","0");
lstManager.Items.Add(li);

foreach (DataRow drManager in _dsData.Tables["manager"].Rows)
{
ListItem liManager = new ListItem((string)drManager["Name"],
((int)drManager["ManagerID"]).ToString());
lstManager.Items.Add(liManager);
}I had this one a while back; turns out I was using simple properties
on a Master Page that required a DataBind() call to bind them. When
it was called, it was also rebinding the content page, which loses the
manually added items.

I recall this issue also happened with an ASCX file on the page, or if
you call a generic DataBind() any time after the addition of
ListItems, etc.

Dunc
http://www.fluidfoundation.com
On 1 Jun, 15:24, mark4asp <mark4...@.gmail.comwrote:

Quote:

Originally Posted by

The first intem in a DropDownList is vanishing!
>
My code to load a DropDownList is shown below. Yet when I load the
page after a postback there is no zeroth item present.
>
lstManager.Items.Clear();
>
lstManager.DataSource = _dsData.Tables["manager"].DefaultView;
lstManager.DataValueField = "ManagerID";
lstManager.DataTextField = "Name";
lstManager.DataBind();
>
lstManager.Items.Insert(0, new ListItem("none", "0"));
>
There's nothing special about the control definition:
>
<asp:DropDownList ID="lstManager" runat="server" Height="20px"
Width="250px" />
>
What's going on here?
>
This was the old code I replaced. Why does the old code (below) work
and why is my new code (above) broke?
>
lstManager.Items.Clear();
>
ListItem li = new ListItem("none","0");
lstManager.Items.Add(li);
>
foreach (DataRow drManager in _dsData.Tables["manager"].Rows)
{
ListItem liManager = new ListItem((string)drManager["Name"],
((int)drManager["ManagerID"]).ToString());
lstManager.Items.Add(liManager);
}


On 1 Jun, 16:30, Dunc <duncan.we...@.gmail.comwrote:

Quote:

Originally Posted by

I had this one a while back; turns out I was using simple properties
on a Master Page that required a DataBind() call to bind them. When
it was called, it was also rebinding the content page, which loses the
manually added items.
>
I recall this issue also happened with an ASCX file on the page, or if
you call a generic DataBind() any time after the addition of
ListItems, etc.
>
Dunchttp://www.fluidfoundation.com
>
On 1 Jun, 15:24, mark4asp <mark4...@.gmail.comwrote:
>
>
>

Quote:

Originally Posted by

The first intem in a DropDownList is vanishing!


>

Quote:

Originally Posted by

My code to load a DropDownList is shown below. Yet when I load the
page after a postback there is no zeroth item present.


>

Quote:

Originally Posted by

lstManager.Items.Clear();


>

Quote:

Originally Posted by

lstManager.DataSource = _dsData.Tables["manager"].DefaultView;
lstManager.DataValueField = "ManagerID";
lstManager.DataTextField = "Name";
lstManager.DataBind();


>

Quote:

Originally Posted by

lstManager.Items.Insert(0, new ListItem("none", "0"));


>

Quote:

Originally Posted by

There's nothing special about the control definition:


>

Quote:

Originally Posted by

<asp:DropDownList ID="lstManager" runat="server" Height="20px"
Width="250px" />


>

Quote:

Originally Posted by

What's going on here?


>

Quote:

Originally Posted by

This was the old code I replaced. Why does the old code (below) work
and why is my new code (above) broke?


>

Quote:

Originally Posted by

lstManager.Items.Clear();


>

Quote:

Originally Posted by

ListItem li = new ListItem("none","0");
lstManager.Items.Add(li);


>

Quote:

Originally Posted by

foreach (DataRow drManager in _dsData.Tables["manager"].Rows)
{
ListItem liManager = new ListItem((string)drManager["Name"],
((int)drManager["ManagerID"]).ToString());
lstManager.Items.Add(liManager);
}- Hide quoted text -


>
- Show quoted text -


Thanks Dunc, for sharing that with me - that scenario you described
sounds very like mine.

The first intem in a DropDownList is vanishing!

The first intem in a DropDownList is vanishing!
My code to load a DropDownList is shown below. Yet when I load the
page after a postback there is no zeroth item present.
lstManager.Items.Clear();
lstManager.DataSource = _dsData.Tables["manager"].DefaultView;
lstManager.DataValueField = "ManagerID";
lstManager.DataTextField = "Name";
lstManager.DataBind();
lstManager.Items.Insert(0, new ListItem("none", "0"));
There's nothing special about the control definition:
<asp:DropDownList ID="lstManager" runat="server" Height="20px"
Width="250px" />
What's going on here?
This was the old code I replaced. Why does the old code (below) work
and why is my new code (above) broke?
lstManager.Items.Clear();
ListItem li = new ListItem("none","0");
lstManager.Items.Add(li);
foreach (DataRow drManager in _dsData.Tables["manager"].Rows)
{
ListItem liManager = new ListItem((string)drManager["Name"],
((int)drManager["ManagerID"]).ToString());
lstManager.Items.Add(liManager);
}I had this one a while back; turns out I was using simple properties
on a Master Page that required a DataBind() call to bind them. When
it was called, it was also rebinding the content page, which loses the
manually added items.
I recall this issue also happened with an ASCX file on the page, or if
you call a generic DataBind() any time after the addition of
ListItems, etc.
Dunc
http://www.fluidfoundation.com
On 1 Jun, 15:24, mark4asp <mark4...@.gmail.com> wrote:
> The first intem in a DropDownList is vanishing!
> My code to load a DropDownList is shown below. Yet when I load the
> page after a postback there is no zeroth item present.
> lstManager.Items.Clear();
> lstManager.DataSource = _dsData.Tables["manager"].DefaultView;
> lstManager.DataValueField = "ManagerID";
> lstManager.DataTextField = "Name";
> lstManager.DataBind();
> lstManager.Items.Insert(0, new ListItem("none", "0"));
> There's nothing special about the control definition:
> <asp:DropDownList ID="lstManager" runat="server" Height="20px"
> Width="250px" />
> What's going on here?
> This was the old code I replaced. Why does the old code (below) work
> and why is my new code (above) broke?
> lstManager.Items.Clear();
> ListItem li = new ListItem("none","0");
> lstManager.Items.Add(li);
> foreach (DataRow drManager in _dsData.Tables["manager"].Rows)
> {
> ListItem liManager = new ListItem((string)drManager["Name"],
> ((int)drManager["ManagerID"]).ToString());
> lstManager.Items.Add(liManager);
> }
On 1 Jun, 16:30, Dunc <duncan.we...@.gmail.com> wrote:
> I had this one a while back; turns out I was using simple properties
> on a Master Page that required a DataBind() call to bind them. When
> it was called, it was also rebinding the content page, which loses the
> manually added items.
> I recall this issue also happened with an ASCX file on the page, or if
> you call a generic DataBind() any time after the addition of
> ListItems, etc.
> Dunchttp://www.fluidfoundation.com
> On 1 Jun, 15:24, mark4asp <mark4...@.gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -
Thanks Dunc, for sharing that with me - that scenario you described
sounds very like mine.

Tuesday, March 13, 2012

The menu and logo section of this site

Hello all,

Hope someone can help me.

On this website, the links on the top section of the page, when clicked, only appear to refresh the content below. This is particulary noticable when clicking the 'Learn' menu item.

Can someone point me in the direction of how to reproduce this for my ASP application. I have been looking at Master Pages, and whilst they do help with consistency in a website, i have not worked out how to postback only some sections of a page, i.e the content bit.

Is there some caching going on? Its not frames. I'm very new to ASP by the way (as you might have guessed).

Angus

Look at the Ajax controls here:http://ajax.asp.net