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

Thursday, March 29, 2012

Newbie: how to handle large response.write blocks

Hi everyone -
Is there a way to abbreviate the aspx below? Specifically, is there a
way to eliminate the response.write syntax and escaped characters?
<%
if (MyObject.SomeBoolean)
{
Response.Write("<div class=\"myclass\">");
Response.Write("You may have won 1,000,000 dollars...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
else
{
Response.Write("<div class=\"error\">");
Response.Write("You should buy more magazines...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
%>
Thanks.
BrianIn C#, Not. If you want to have a literal quote in a string you have to plac
e
the \ escape before it.
Regarding not having to type Response.Write so much, try stuffing all your
strings into a StringBuilder instance. At the end, you can write one time:
Response.Write(myStringBuilder.ToString());
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Brian F" wrote:

> Hi everyone -
> Is there a way to abbreviate the aspx below? Specifically, is there a
> way to eliminate the response.write syntax and escaped characters?
> <%
> if (MyObject.SomeBoolean)
> {
> Response.Write("<div class=\"myclass\">");
> Response.Write("You may have won 1,000,000 dollars...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> else
> {
> Response.Write("<div class=\"error\">");
> Response.Write("You should buy more magazines...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> %>
> Thanks.
> Brian
>

Newbie: how to handle large response.write blocks

Hi everyone -

Is there a way to abbreviate the aspx below? Specifically, is there a
way to eliminate the response.write syntax and escaped characters?

<%
if (MyObject.SomeBoolean)
{
Response.Write("<div class=\"myclass\">");
Response.Write("You may have won 1,000,000 dollars...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
else
{
Response.Write("<div class=\"error\">");
Response.Write("You should buy more magazines...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
%
Thanks.
BrianIn C#, Not. If you want to have a literal quote in a string you have to place
the \ escape before it.

Regarding not having to type Response.Write so much, try stuffing all your
strings into a StringBuilder instance. At the end, you can write one time:
Response.Write(myStringBuilder.ToString());
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"Brian F" wrote:

> Hi everyone -
> Is there a way to abbreviate the aspx below? Specifically, is there a
> way to eliminate the response.write syntax and escaped characters?
> <%
> if (MyObject.SomeBoolean)
> {
> Response.Write("<div class=\"myclass\">");
> Response.Write("You may have won 1,000,000 dollars...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> else
> {
> Response.Write("<div class=\"error\">");
> Response.Write("You should buy more magazines...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> %>
> Thanks.
> Brian
>

newbie: Instance failure!

Hey

asp.net 2.0

When I run the code below I get the runtime error "Instance Failure"

public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}

The error occur at this line:
"IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);"

Just in case, here is a copy of my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
</appSettings>
<connectionStrings>
<add name="aspnet_DB" connectionString="Data
Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
</connectionStrings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

My gut feeling tells me it might be caused by the db connectionsting, but
I'm not sure... I'm trying to connect to the express database within the
project!

Any suggestions to what I should do to fix this?

Jeff"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:ueLDl0PnGHA.1444@.TK2MSFTNGP02.phx.gbl...
> Hey
>
> asp.net 2.0
>
> When I run the code below I get the runtime error "Instance Failure"
>
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
>
> The error occur at this line:
> "IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);"
>
> Just in case, here is a copy of my web.config file:
> <?xml version="1.0"?>
> <configuration
> xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <appSettings>
> </appSettings>
> <connectionStrings>
> <add name="aspnet_DB" connectionString="Data
> Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
> Instance=true" />
> </connectionStrings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
>
> My gut feeling tells me it might be caused by the db connectionsting, but
> I'm not sure... I'm trying to connect to the express database within the
> project!
>
> Any suggestions to what I should do to fix this?
>
> Jeff
>

Monday, March 26, 2012

newbie: my code crashe, NULL value

Hey
asp.net 2.0
My code below crashes at the "return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;"
line. In the debugging window I see that when this exception occur, the
"return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;" has a NULL value...
public override int SendMessage(MessageDetails message)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.receiver", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@dotnet.itags.org.sender", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@dotnet.itags.org.title", SqlDbType.NVarChar).Value =
message.Title;
cmd.Parameters.Add("@dotnet.itags.org.body", SqlDbType.NVarChar).Value =
message.Body;
cmd.Parameters.Add("@dotnet.itags.org.return", SqlDbType.Int).Direction =
ParameterDirection.Output;
cn.Open();
int ret = ExecuteNonQuery(cmd);
return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;
}
}
This is the stored procdure called in the method:
ALTER PROCEDURE dbo.AH_network_SendMessages
@dotnet.itags.org.sender nvarchar(256),
@dotnet.itags.org.receiver nvarchar(256),
@dotnet.itags.org.title nvarchar(100),
@dotnet.itags.org.body nvarchar(2000),
@dotnet.itags.org.return int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO AH_Messages (sender, receiver, title, body)
VALUES (@dotnet.itags.org.sender, @dotnet.itags.org.receiver, @dotnet.itags.org.title, @dotnet.itags.org.body);
set @dotnet.itags.org.return = 1;
select 1;
END
Please, what am I doing wrong here?
JeffIf altering the signature of your SP, you may consider the following option
that should work.
SqlParameter returnValue = sqlCommand.Parameters.Add("@.YourSPReturnValue",
SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
return (Int32)returnValue.Value;
Declaring an explicit return value is in my opinion preferrable, as it is
more clear about your intent and somewhat cleans up the SP declaration.
Tor Bdshaug
tor.badshaug(AT)bekk.no
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...
> Hey
> asp.net 2.0
> My code below crashes at the "return
> (int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
> that when this exception occur, the "return
> (int)cmd.Parameters["@.return"].Value;" has a NULL value...
> public override int SendMessage(MessageDetails message)
> {
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
> message.Title;
> cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
> message.Body;
> cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
> ParameterDirection.Output;
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> return (int)cmd.Parameters["@.return"].Value;
> }
> }
> This is the stored procdure called in the method:
> ALTER PROCEDURE dbo.AH_network_SendMessages
> @.sender nvarchar(256),
> @.receiver nvarchar(256),
> @.title nvarchar(100),
> @.body nvarchar(2000),
> @.return int OUTPUT
> AS
> BEGIN
> SET NOCOUNT ON;
> INSERT INTO AH_Messages (sender, receiver, title, body)
> VALUES (@.sender, @.receiver, @.title, @.body);
> set @.return = 1;
> select 1;
> END
> Please, what am I doing wrong here?
> Jeff
>
What is the ExecuteNonQuery method you try to call after all?
Normally, you will do a cmd.ExecuteNonQuery, rather than
ExecuteNonQuery(cmd).
Could it be that your ExecuteNonQuery(SqlCommand cmd) method in somewhat
fail to do a cmd.ExecuteNonQuery.
The fact that the output parameter does not have a value may suggest that
may be the case.
Tor Bdshaug
tor.badshaug(AT)bekk.no
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...
> Hey
> asp.net 2.0
> My code below crashes at the "return
> (int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
> that when this exception occur, the "return
> (int)cmd.Parameters["@.return"].Value;" has a NULL value...
> public override int SendMessage(MessageDetails message)
> {
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
> message.Title;
> cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
> message.Body;
> cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
> ParameterDirection.Output;
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> return (int)cmd.Parameters["@.return"].Value;
> }
> }
> This is the stored procdure called in the method:
> ALTER PROCEDURE dbo.AH_network_SendMessages
> @.sender nvarchar(256),
> @.receiver nvarchar(256),
> @.title nvarchar(100),
> @.body nvarchar(2000),
> @.return int OUTPUT
> AS
> BEGIN
> SET NOCOUNT ON;
> INSERT INTO AH_Messages (sender, receiver, title, body)
> VALUES (@.sender, @.receiver, @.title, @.body);
> set @.return = 1;
> select 1;
> END
> Please, what am I doing wrong here?
> Jeff
>
I am not sure why you are selecting 1 after setting the @.return. There is no
need unless you are doing something with it. Since you are ExecuteNonQuery,
this is a wasted cycle.
Next, why are you not testing "ret" in your code. If it is -1, the insert
failed for some reason. By testing that you could determine what your issue
is.
Also, why have you not wrapped the open and ExecuteNonQuery() in a try. Here
is a good pattern:
try
{
cn.Open();
int ret = ExecuteNonQuery(cmd);
}
finally
{
cn.Dispose();
}
Not sure what you are returning.
Next suggestion. Do not return until you test the parameter. If it is is
null, the cast to int will blow up (nice technical term ;-> ).
Be careful with calling thisgs return in a stored proc, as SQL Server
already returns a value (even if you do not declare it) called
@.RETURN_VALUE.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
****************************************
*********
Think Outside the Box!
****************************************
*********
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...
> Hey
> asp.net 2.0
> My code below crashes at the "return
> (int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
> that when this exception occur, the "return
> (int)cmd.Parameters["@.return"].Value;" has a NULL value...
> public override int SendMessage(MessageDetails message)
> {
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
> message.Sender;
> cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
> message.Title;
> cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
> message.Body;
> cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
> ParameterDirection.Output;
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> return (int)cmd.Parameters["@.return"].Value;
> }
> }
> This is the stored procdure called in the method:
> ALTER PROCEDURE dbo.AH_network_SendMessages
> @.sender nvarchar(256),
> @.receiver nvarchar(256),
> @.title nvarchar(100),
> @.body nvarchar(2000),
> @.return int OUTPUT
> AS
> BEGIN
> SET NOCOUNT ON;
> INSERT INTO AH_Messages (sender, receiver, title, body)
> VALUES (@.sender, @.receiver, @.title, @.body);
> set @.return = 1;
> select 1;
> END
> Please, what am I doing wrong here?
> Jeff
>
Thanks, the error was in the ExecuteNonQuery method, which is just a wrapper
around SqlCommand.ExecuteNonQuery... It's solved now, thanks to your tip
about checking ExecuteNonQuery
"Tor Bdshaug" <tor.badshaug@.nospam.com> wrote in message
news:%23TqCCAw6GHA.4996@.TK2MSFTNGP04.phx.gbl...
> What is the ExecuteNonQuery method you try to call after all?
> Normally, you will do a cmd.ExecuteNonQuery, rather than
> ExecuteNonQuery(cmd).
> Could it be that your ExecuteNonQuery(SqlCommand cmd) method in somewhat
> fail to do a cmd.ExecuteNonQuery.
> The fact that the output parameter does not have a value may suggest that
> may be the case.
> Tor Bdshaug
> tor.badshaug(AT)bekk.no
> "Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
> news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...
>
Hey
Thanks, yes selecting 1 after setting the @.return to 1 is bad programming. I
know it, I will later rewrite this stored procedure and then I will fix
this.. the procedure is also missing a commit/rollback... I guess auto
commit is enabled but I prefer using explicit transaction...
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
message news:ON3X9Jw6GHA.2288@.TK2MSFTNGP05.phx.gbl...
>I am not sure why you are selecting 1 after setting the @.return. There is
>no need unless you are doing something with it. Since you are
>ExecuteNonQuery, this is a wasted cycle.
> Next, why are you not testing "ret" in your code. If it is -1, the insert
> failed for some reason. By testing that you could determine what your
> issue is.
> Also, why have you not wrapped the open and ExecuteNonQuery() in a try.
> Here is a good pattern:
> try
> {
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> }
> finally
> {
> cn.Dispose();
> }
> Not sure what you are returning.
> Next suggestion. Do not return until you test the parameter. If it is is
> null, the cast to int will blow up (nice technical term ;-> ).
> Be careful with calling thisgs return in a stored proc, as SQL Server
> already returns a value (even if you do not declare it) called
> @.RETURN_VALUE.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com/
> ****************************************
*********
> Think Outside the Box!
> ****************************************
*********
> "Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
> news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...
>

newbie: my code crashe, NULL value

Hey

asp.net 2.0

My code below crashes at the "return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;"
line. In the debugging window I see that when this exception occur, the
"return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;" has a NULL value...

public override int SendMessage(MessageDetails message)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.receiver", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@dotnet.itags.org.sender", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@dotnet.itags.org.title", SqlDbType.NVarChar).Value =
message.Title;
cmd.Parameters.Add("@dotnet.itags.org.body", SqlDbType.NVarChar).Value =
message.Body;
cmd.Parameters.Add("@dotnet.itags.org.return", SqlDbType.Int).Direction =
ParameterDirection.Output;
cn.Open();
int ret = ExecuteNonQuery(cmd);
return (int)cmd.Parameters["@dotnet.itags.org.return"].Value;
}
}

This is the stored procdure called in the method:
ALTER PROCEDURE dbo.AH_network_SendMessages
@dotnet.itags.org.sender nvarchar(256),
@dotnet.itags.org.receiver nvarchar(256),
@dotnet.itags.org.title nvarchar(100),
@dotnet.itags.org.body nvarchar(2000),
@dotnet.itags.org.return int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO AH_Messages (sender, receiver, title, body)
VALUES (@dotnet.itags.org.sender, @dotnet.itags.org.receiver, @dotnet.itags.org.title, @dotnet.itags.org.body);

set @dotnet.itags.org.return = 1;
select 1;
END

Please, what am I doing wrong here?

JeffIf altering the signature of your SP, you may consider the following option
that should work.

SqlParameter returnValue = sqlCommand.Parameters.Add("@.YourSPReturnValue",
SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
return (Int32)returnValue.Value;

Declaring an explicit return value is in my opinion preferrable, as it is
more clear about your intent and somewhat cleans up the SP declaration.

Tor Bdshaug
tor.badshaug(AT)bekk.no

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hey
>
asp.net 2.0
>
My code below crashes at the "return
(int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
that when this exception occur, the "return
(int)cmd.Parameters["@.return"].Value;" has a NULL value...
>
public override int SendMessage(MessageDetails message)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
message.Title;
cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
message.Body;
cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
ParameterDirection.Output;
cn.Open();
int ret = ExecuteNonQuery(cmd);
return (int)cmd.Parameters["@.return"].Value;
}
}
>
This is the stored procdure called in the method:
ALTER PROCEDURE dbo.AH_network_SendMessages
@.sender nvarchar(256),
@.receiver nvarchar(256),
@.title nvarchar(100),
@.body nvarchar(2000),
@.return int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO AH_Messages (sender, receiver, title, body)
VALUES (@.sender, @.receiver, @.title, @.body);
>
set @.return = 1;
select 1;
END
>
Please, what am I doing wrong here?
>
Jeff
>


What is the ExecuteNonQuery method you try to call after all?
Normally, you will do a cmd.ExecuteNonQuery, rather than
ExecuteNonQuery(cmd).
Could it be that your ExecuteNonQuery(SqlCommand cmd) method in somewhat
fail to do a cmd.ExecuteNonQuery.
The fact that the output parameter does not have a value may suggest that
may be the case.

Tor Bdshaug
tor.badshaug(AT)bekk.no

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hey
>
asp.net 2.0
>
My code below crashes at the "return
(int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
that when this exception occur, the "return
(int)cmd.Parameters["@.return"].Value;" has a NULL value...
>
public override int SendMessage(MessageDetails message)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
message.Title;
cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
message.Body;
cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
ParameterDirection.Output;
cn.Open();
int ret = ExecuteNonQuery(cmd);
return (int)cmd.Parameters["@.return"].Value;
}
}
>
This is the stored procdure called in the method:
ALTER PROCEDURE dbo.AH_network_SendMessages
@.sender nvarchar(256),
@.receiver nvarchar(256),
@.title nvarchar(100),
@.body nvarchar(2000),
@.return int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO AH_Messages (sender, receiver, title, body)
VALUES (@.sender, @.receiver, @.title, @.body);
>
set @.return = 1;
select 1;
END
>
Please, what am I doing wrong here?
>
Jeff
>


Thanks, the error was in the ExecuteNonQuery method, which is just a wrapper
around SqlCommand.ExecuteNonQuery... It's solved now, thanks to your tip
about checking ExecuteNonQuery

"Tor Bdshaug" <tor.badshaug@.nospam.comwrote in message
news:%23TqCCAw6GHA.4996@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

What is the ExecuteNonQuery method you try to call after all?
Normally, you will do a cmd.ExecuteNonQuery, rather than
ExecuteNonQuery(cmd).
Could it be that your ExecuteNonQuery(SqlCommand cmd) method in somewhat
fail to do a cmd.ExecuteNonQuery.
The fact that the output parameter does not have a value may suggest that
may be the case.
>
Tor Bdshaug
tor.badshaug(AT)bekk.no
>
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Hey
>>
>asp.net 2.0
>>
>My code below crashes at the "return
>(int)cmd.Parameters["@.return"].Value;" line. In the debugging window I
>see that when this exception occur, the "return
>(int)cmd.Parameters["@.return"].Value;" has a NULL value...
>>
>public override int SendMessage(MessageDetails message)
>{
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
>message.Sender;
> cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
>message.Sender;
> cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
>message.Title;
> cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
>message.Body;
> cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
>ParameterDirection.Output;
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> return (int)cmd.Parameters["@.return"].Value;
> }
>}
>>
>This is the stored procdure called in the method:
>ALTER PROCEDURE dbo.AH_network_SendMessages
>@.sender nvarchar(256),
>@.receiver nvarchar(256),
>@.title nvarchar(100),
>@.body nvarchar(2000),
>@.return int OUTPUT
>AS
>BEGIN
>SET NOCOUNT ON;
>INSERT INTO AH_Messages (sender, receiver, title, body)
> VALUES (@.sender, @.receiver, @.title, @.body);
>>
>set @.return = 1;
>select 1;
>END
>>
>Please, what am I doing wrong here?
>>
>Jeff
>>


>
>


I am not sure why you are selecting 1 after setting the @.return. There is no
need unless you are doing something with it. Since you are ExecuteNonQuery,
this is a wasted cycle.

Next, why are you not testing "ret" in your code. If it is -1, the insert
failed for some reason. By testing that you could determine what your issue
is.

Also, why have you not wrapped the open and ExecuteNonQuery() in a try. Here
is a good pattern:

try
{
cn.Open();
int ret = ExecuteNonQuery(cmd);
}
finally
{
cn.Dispose();
}

Not sure what you are returning.

Next suggestion. Do not return until you test the parameter. If it is is
null, the cast to int will blow up (nice technical term ;->).

Be careful with calling thisgs return in a stored proc, as SQL Server
already returns a value (even if you do not declare it) called
@.RETURN_VALUE.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
*************************************************
Think Outside the Box!
*************************************************
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hey
>
asp.net 2.0
>
My code below crashes at the "return
(int)cmd.Parameters["@.return"].Value;" line. In the debugging window I see
that when this exception occur, the "return
(int)cmd.Parameters["@.return"].Value;" has a NULL value...
>
public override int SendMessage(MessageDetails message)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
message.Sender;
cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
message.Title;
cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
message.Body;
cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
ParameterDirection.Output;
cn.Open();
int ret = ExecuteNonQuery(cmd);
return (int)cmd.Parameters["@.return"].Value;
}
}
>
This is the stored procdure called in the method:
ALTER PROCEDURE dbo.AH_network_SendMessages
@.sender nvarchar(256),
@.receiver nvarchar(256),
@.title nvarchar(100),
@.body nvarchar(2000),
@.return int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO AH_Messages (sender, receiver, title, body)
VALUES (@.sender, @.receiver, @.title, @.body);
>
set @.return = 1;
select 1;
END
>
Please, what am I doing wrong here?
>
Jeff
>


Hey

Thanks, yes selecting 1 after setting the @.return to 1 is bad programming. I
know it, I will later rewrite this stored procedure and then I will fix
this.. the procedure is also missing a commit/rollback... I guess auto
commit is enabled but I prefer using explicit transaction...

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamMwrote in
message news:ON3X9Jw6GHA.2288@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>I am not sure why you are selecting 1 after setting the @.return. There is
>no need unless you are doing something with it. Since you are
>ExecuteNonQuery, this is a wasted cycle.
>
Next, why are you not testing "ret" in your code. If it is -1, the insert
failed for some reason. By testing that you could determine what your
issue is.
>
Also, why have you not wrapped the open and ExecuteNonQuery() in a try.
Here is a good pattern:
>
try
{
cn.Open();
int ret = ExecuteNonQuery(cmd);
}
finally
{
cn.Dispose();
}
>
Not sure what you are returning.
>
Next suggestion. Do not return until you test the parameter. If it is is
null, the cast to int will blow up (nice technical term ;->).
>
Be careful with calling thisgs return in a stored proc, as SQL Server
already returns a value (even if you do not declare it) called
@.RETURN_VALUE.
>
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
>
*************************************************
Think Outside the Box!
*************************************************
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:unl2osv6GHA.4580@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Hey
>>
>asp.net 2.0
>>
>My code below crashes at the "return
>(int)cmd.Parameters["@.return"].Value;" line. In the debugging window I
>see that when this exception occur, the "return
>(int)cmd.Parameters["@.return"].Value;" has a NULL value...
>>
>public override int SendMessage(MessageDetails message)
>{
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("AH_network_SendMessages", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.receiver", SqlDbType.NVarChar).Value =
>message.Sender;
> cmd.Parameters.Add("@.sender", SqlDbType.NVarChar).Value =
>message.Sender;
> cmd.Parameters.Add("@.title", SqlDbType.NVarChar).Value =
>message.Title;
> cmd.Parameters.Add("@.body", SqlDbType.NVarChar).Value =
>message.Body;
> cmd.Parameters.Add("@.return", SqlDbType.Int).Direction =
>ParameterDirection.Output;
> cn.Open();
> int ret = ExecuteNonQuery(cmd);
> return (int)cmd.Parameters["@.return"].Value;
> }
>}
>>
>This is the stored procdure called in the method:
>ALTER PROCEDURE dbo.AH_network_SendMessages
>@.sender nvarchar(256),
>@.receiver nvarchar(256),
>@.title nvarchar(100),
>@.body nvarchar(2000),
>@.return int OUTPUT
>AS
>BEGIN
>SET NOCOUNT ON;
>INSERT INTO AH_Messages (sender, receiver, title, body)
> VALUES (@.sender, @.receiver, @.title, @.body);
>>
>set @.return = 1;
>select 1;
>END
>>
>Please, what am I doing wrong here?
>>
>Jeff
>>


>
>

newbie: Need help with this bug/exception

Hey

ASP.NET 2.0

this code "private MembershipUserCollection allUsers =
Membership.GetAllUsers();" crashes my web portal. Below you see the inner
exception

Innet Exception:

System.Configuration.ConfigurationErrorsException was unhandled by user code
Message="Could not load file or assembly 'System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' or one of its dependencies.
The system cannot find the file specified. (C:\\Documents and
Settings\\Test\\My Documents\\Visual Studio 2005\\WebSites\\Test\\web.config
line 53)"
Source="System.Web"
BareMessage="Could not load file or assembly 'System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' or one of its dependencies.
The system cannot find the file specified."
Filename="C:\\Documents and Settings\\Test\\My Documents\\Visual Studio
2005\\WebSites\\Test\\web.config"
Line=53
StackTrace:
at System.Web.Configuration.ConfigUtil.GetType(String typeName,
String propertyName, ConfigurationElement configElement, XmlNode node,
Boolean checkAptcaBit, Boolean ignoreCase)
at System.Web.Configuration.ConfigUtil.GetType(String typeName,
String propertyName, ConfigurationElement configElement, Boolean
checkAptcaBit, Boolean ignoreCase)
at
System.Web.Configuration.ProvidersHelper.Instantia teProvider(ProviderSettings
providerSettings, Type providerType)
at
System.Web.Configuration.ProvidersHelper.Instantia teProviders(ProviderSettingsCollection
configProviders, ProviderCollection providers, Type providerType)
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Provider()
at System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32
pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers()
at Admin_Default..ctor() in c:\Documents and Settings\Test\My
Documents\Visual Studio 2005\WebSites\Test\Admin\Default.aspx.cs:line 14
at ASP.admin_default_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\Test\0570c87d\5d2b6186\App_Web_suvoevfs.0.cs :line 0
at
__ASP.FastObjectFactory_app_web_suvoevfs.Create_AS P_admin_default_aspx() in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\Test\0570c87d\5d2b6186\App_Web_suvoevfs.2.cs :line 0
at System.Web.Compilation.BuildResultCompiledType.Cre ateInstance()
at
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
at
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context,
String requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig)
at
System.Web.HttpApplication.MapHandlerExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)

This is my membership provider (web.config)

<membership defaultProvider="AH_MembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<add name="AH_MembershipProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Encrypted"
maxInvalidPasswordAttempts="5"
passwordAttemptWindows="10"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' " />
</providers>
</membership>

Any suggestions on how to solve this problem?

Best Regards

JeffThere are instances where you need to strip out the garbage from a site,
esp. if you publish instead of just copy all source (the latter being a bad
thing in a production site). Open the web config and remove the assemblies
add lines for the dlls in question (under <compilation>). If you have
already compiled (published), they are not needed anyway. That is what I
would try first. If it does not work, follow up and the issue can be dug
into deeper.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:uwrVWnR3GHA.1568@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hey
>
ASP.NET 2.0
>
this code "private MembershipUserCollection allUsers =
Membership.GetAllUsers();" crashes my web portal. Below you see the inner
exception
>
Innet Exception:
>
System.Configuration.ConfigurationErrorsException was unhandled by user
code
Message="Could not load file or assembly 'System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' or one of its
dependencies. The system cannot find the file specified. (C:\\Documents
and Settings\\Test\\My Documents\\Visual Studio
2005\\WebSites\\Test\\web.config line 53)"
Source="System.Web"
BareMessage="Could not load file or assembly 'System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' or one
of its dependencies. The system cannot find the file specified."
Filename="C:\\Documents and Settings\\Test\\My Documents\\Visual Studio
2005\\WebSites\\Test\\web.config"
Line=53
StackTrace:
at System.Web.Configuration.ConfigUtil.GetType(String typeName,
String propertyName, ConfigurationElement configElement, XmlNode node,
Boolean checkAptcaBit, Boolean ignoreCase)
at System.Web.Configuration.ConfigUtil.GetType(String typeName,
String propertyName, ConfigurationElement configElement, Boolean
checkAptcaBit, Boolean ignoreCase)
at
System.Web.Configuration.ProvidersHelper.Instantia teProvider(ProviderSettings
providerSettings, Type providerType)
at
System.Web.Configuration.ProvidersHelper.Instantia teProviders(ProviderSettingsCollection
configProviders, ProviderCollection providers, Type providerType)
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Provider()
at System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32
pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers()
at Admin_Default..ctor() in c:\Documents and Settings\Test\My
Documents\Visual Studio 2005\WebSites\Test\Admin\Default.aspx.cs:line 14
at ASP.admin_default_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\Test\0570c87d\5d2b6186\App_Web_suvoevfs.0.cs :line 0
at
__ASP.FastObjectFactory_app_web_suvoevfs.Create_AS P_admin_default_aspx()
in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\Test\0570c87d\5d2b6186\App_Web_suvoevfs.2.cs :line 0
at System.Web.Compilation.BuildResultCompiledType.Cre ateInstance()
at
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
at
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpCont ext context,
String requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig)
at
System.Web.HttpApplication.MapHandlerExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)
>
>
This is my membership provider (web.config)
>
<membership defaultProvider="AH_MembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<add name="AH_MembershipProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Encrypted"
maxInvalidPasswordAttempts="5"
passwordAttemptWindows="10"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaa' " />
</providers>
</membership>
>
Any suggestions on how to solve this problem?
>
Best Regards
>
Jeff
>
>

Saturday, March 24, 2012

newbie: runtime error

Hey
asp.net 2.0
When I run the code below I get a runtime error ("Object reference not set
to an instance of an object. "):
Here is the code:
public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}
The error occur at this line in the code:
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
Just in case here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDire
ctory|aspnetdb.mdf;User
Instance=true" />
</appSettings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>
Any ideas what I'm doing wrong here?
JeffJeff wrote:
> Hey
> asp.net 2.0
>
> When I run the code below I get a runtime error ("Object reference not set
> to an instance of an object. "):
> Here is the code:
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
> The error occur at this line in the code:
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> Just in case here is my web.config file:
> <?xml version="1.0"?>
> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"
> <appSettings>
> <add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDire
ctory|aspnetdb.mdf;User
> Instance=true" />
> </appSettings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
> Any ideas what I'm doing wrong here?
> Jeff
Hi Jeff,
If looks like css is null. I'm guessing this is because there is no
<connectionStrings> in the web.config.
See http://www.devx.com/dotnet/Article/27562
David Hogue

newbie: runtime error

Hey

asp.net 2.0

When I run the code below I get a runtime error ("Object reference not set
to an instance of an object. "):

Here is the code:

public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}

The error occur at this line in the code:
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");

Just in case here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
</appSettings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

Any ideas what I'm doing wrong here?

JeffJeff wrote:
> Hey
>
> asp.net 2.0
>
>
> When I run the code below I get a runtime error ("Object reference not set
> to an instance of an object. "):
>
> Here is the code:
>
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
>
> The error occur at this line in the code:
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
>
> Just in case here is my web.config file:
> <?xml version="1.0"?>
> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <appSettings>
> <add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
> Instance=true" />
> </appSettings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
>
> Any ideas what I'm doing wrong here?
>
> Jeff

Hi Jeff,

If looks like css is null. I'm guessing this is because there is no
<connectionStrings> in the web.config.

See http://www.devx.com/dotnet/Article/27562
--
David Hogue

Newbie: switch control

I try to create a switch control, but I'm hitting a problem, changing the
switch value with button in the page (below failig test code).
I know in this test case I could create an extra variable and use it, my
problem is the switch, i my real problem is in a repeater, hence I cannot
use a property!
how to change the label of the galador:Switch?
--
<script runat="server">
void OnSwapSwitch(object sender, EventArgs e)
{
switch (mySwitch.Value)
{
case "0":
mySwitch.Value = "1";
break;
default:
mySwitch.Value = "0";
break;
}
}
</script>
<galador:Switch id=mySwitch runat=server Value=1 >
<galador:SwitchCase runat=server label=0>
Azerty
<asp:LinkButton ID="LinkButton1" Runat=server
OnClick=OnSwapSwitch >Clic
Clac</asp:LinkButton>
</galador:SwitchCase>
<galador:SwitchCase runat=server label=1>
Qwerty
<asp:LinkButton ID="LinkButton2" Runat=server
OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
</galador:SwitchCase>
</galador:Switch>Have you tried to databind your value to some variable? For example, when
you switch, in your back-end code, if you set some variable ( string MyVar =
"";), then do a Page.DataBind(), then you can access it in your ascx/aspx
code using something like this... <galador:SwitchCase runat=server
label="<%= MyVar %>">
Would that work for you?
Alex
"Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
> I try to create a switch control, but I'm hitting a problem, changing the
> switch value with button in the page (below failig test code).
> I know in this test case I could create an extra variable and use it, my
> problem is the switch, i my real problem is in a repeater, hence I cannot
> use a property!
> how to change the label of the galador:Switch?
> --
> <script runat="server">
> void OnSwapSwitch(object sender, EventArgs e)
> {
> switch (mySwitch.Value)
> {
> case "0":
> mySwitch.Value = "1";
> break;
> default:
> mySwitch.Value = "0";
> break;
> }
> }
> </script>
> <galador:Switch id=mySwitch runat=server Value=1 >
> <galador:SwitchCase runat=server label=0>
> Azerty
> <asp:LinkButton ID="LinkButton1" Runat=server
> OnClick=OnSwapSwitch >Clic
> Clac</asp:LinkButton>
> </galador:SwitchCase>
> <galador:SwitchCase runat=server label=1>
> Qwerty
> <asp:LinkButton ID="LinkButton2" Runat=server
> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
> </galador:SwitchCase>
> </galador:Switch>
>
well, I guess I will have too...
but what I wonder is, my switch is in a repeater, how could I store the
value in a variable?
"Alex" <Alex@.donotemailme.com> wrote in message
news:uE1nVCGxEHA.1984@.TK2MSFTNGP14.phx.gbl...
> Have you tried to databind your value to some variable? For example, when
> you switch, in your back-end code, if you set some variable ( string MyVar
> =
> "";), then do a Page.DataBind(), then you can access it in your ascx/aspx
> code using something like this... <galador:SwitchCase runat=server
> label="<%= MyVar %>">
> Would that work for you?
> --
> Alex
> "Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
> news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
>

Newbie: switch control

I try to create a switch control, but I'm hitting a problem, changing the
switch value with button in the page (below failig test code).

I know in this test case I could create an extra variable and use it, my
problem is the switch, i my real problem is in a repeater, hence I cannot
use a property!

how to change the label of the galador:Switch?
----------
<script runat="server">
void OnSwapSwitch(object sender, EventArgs e)
{
switch (mySwitch.Value)
{
case "0":
mySwitch.Value = "1";
break;
default:
mySwitch.Value = "0";
break;
}
}
</script
<galador:Switch id=mySwitch runat=server Value=1
<galador:SwitchCase runat=server label=0>
Azerty
<asp:LinkButton ID="LinkButton1" Runat=server
OnClick=OnSwapSwitch >Clic
Clac</asp:LinkButton>
</galador:SwitchCase
<galador:SwitchCase runat=server label=1>
Qwerty
<asp:LinkButton ID="LinkButton2" Runat=server
OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
</galador:SwitchCase
</galador:SwitchHave you tried to databind your value to some variable? For example, when
you switch, in your back-end code, if you set some variable ( string MyVar =
"";), then do a Page.DataBind(), then you can access it in your ascx/aspx
code using something like this... <galador:SwitchCase runat=server
label="<%= MyVar %>"
Would that work for you?

--
Alex

"Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
> I try to create a switch control, but I'm hitting a problem, changing the
> switch value with button in the page (below failig test code).
> I know in this test case I could create an extra variable and use it, my
> problem is the switch, i my real problem is in a repeater, hence I cannot
> use a property!
> how to change the label of the galador:Switch?
> ----------
> <script runat="server">
> void OnSwapSwitch(object sender, EventArgs e)
> {
> switch (mySwitch.Value)
> {
> case "0":
> mySwitch.Value = "1";
> break;
> default:
> mySwitch.Value = "0";
> break;
> }
> }
> </script>
> <galador:Switch id=mySwitch runat=server Value=1 >
> <galador:SwitchCase runat=server label=0>
> Azerty
> <asp:LinkButton ID="LinkButton1" Runat=server
> OnClick=OnSwapSwitch >Clic
> Clac</asp:LinkButton>
> </galador:SwitchCase>
> <galador:SwitchCase runat=server label=1>
> Qwerty
> <asp:LinkButton ID="LinkButton2" Runat=server
> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
> </galador:SwitchCase>
> </galador:Switch>
well, I guess I will have too...
but what I wonder is, my switch is in a repeater, how could I store the
value in a variable?

"Alex" <Alex@.donotemailme.com> wrote in message
news:uE1nVCGxEHA.1984@.TK2MSFTNGP14.phx.gbl...
> Have you tried to databind your value to some variable? For example, when
> you switch, in your back-end code, if you set some variable ( string MyVar
> =
> "";), then do a Page.DataBind(), then you can access it in your ascx/aspx
> code using something like this... <galador:SwitchCase runat=server
> label="<%= MyVar %>">
> Would that work for you?
> --
> Alex
> "Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
> news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
>> I try to create a switch control, but I'm hitting a problem, changing the
>> switch value with button in the page (below failig test code).
>>
>> I know in this test case I could create an extra variable and use it, my
>> problem is the switch, i my real problem is in a repeater, hence I cannot
>> use a property!
>>
>> how to change the label of the galador:Switch?
>> ----------
>> <script runat="server">
>> void OnSwapSwitch(object sender, EventArgs e)
>> {
>> switch (mySwitch.Value)
>> {
>> case "0":
>> mySwitch.Value = "1";
>> break;
>> default:
>> mySwitch.Value = "0";
>> break;
>> }
>> }
>> </script>
>>
>> <galador:Switch id=mySwitch runat=server Value=1 >
>>
>> <galador:SwitchCase runat=server label=0>
>> Azerty
>> <asp:LinkButton ID="LinkButton1" Runat=server
>> OnClick=OnSwapSwitch >Clic
>> Clac</asp:LinkButton>
>> </galador:SwitchCase>
>>
>> <galador:SwitchCase runat=server label=1>
>> Qwerty
>> <asp:LinkButton ID="LinkButton2" Runat=server
>> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
>> </galador:SwitchCase>
>>
>> </galador:Switch>
>>
>>

Thursday, March 22, 2012

Newbie:Simple 'textbox' causing this error ?

In VS 2005, I attempt to build my VB (.aspx) application:
I simply drag and drop a Label text and a "textbox".
When I hit F5, I get the error below. Obviously it is being caused by
something missing the in the 'textbox' property. What's wrong ?
Server Error in '/P2' Application.
----
--
Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with
runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'TextBox1' of type
'TextBox' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control 'TextBox1' of type 'TextBox' must be
placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +160
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
writer) +45
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
writer) +22
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +61
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
adapter) +302
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +167
System.Web.UI.Page.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +61
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
adapter) +302
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6607
----
--
Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NET
Version:2.0.40607.16
Here is the source code:
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub
Sub TextBox1_TextChanged1(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub
</script>
<script language="javascript" type="text/javascript" for="document"
event="ondatasetcomplete">
<!--
return document_ondatasetcomplete()
// -->
</script>
<script language="javascript" type="text/javascript">
<!--
function document_ondatasetcomplete() {
}
// -->
</script>
<span style="font-family: Tahoma; background-color: #ffffff"></span>
<br />
<table enableviewstate="true">
<tr>
<td style="width: 325px">
<asp:label id="Label1" runat="server" text="1. What's your
favorite pet's name ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px">
</td>
</tr>
<tr>
<td style="width: 325px; height: 21px">
<asp:label id="Label2" runat="server" text="2. What's your
mother's birthday ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px; height: 21px">
</td>
</tr>
<tr>
<td style="width: 325px">
<asp:label id="Label3" runat="server" text="3. What's your
father's first name ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px">
</td>
</tr>
</table>
<br />
<asp:textbox id="TextBox1" runat="server"></asp:textbox>Go at design mode of your form, click html view and ensure that
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
control is within <form> tag
you cannot place an asp control outside the <form> tag
"Mr. Magoo" <maggo@.nospasm.com> wrote in message news:<e3bTJqFJFHA.904@.tk2msftngp13.phx.gbl
>...
> In VS 2005, I attempt to build my VB (.aspx) application:
> I simply drag and drop a Label text and a "textbox".
> When I hit F5, I get the error below. Obviously it is being caused by
> something missing the in the 'textbox' property. What's wrong ?
> Server Error in '/P2' Application.
> ----
--
> Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with
> runat=server.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Web.HttpException: Control 'TextBox1' of type
> 'TextBox' must be placed inside a form tag with runat=server.
> Source Error:
> An unhandled exception was generated during the execution of the current w
eb
> request. Information regarding the origin and location of the exception ca
n
> be identified using the exception stack trace below.
> Stack Trace:
>
> [HttpException (0x80004005): Control 'TextBox1' of type 'TextBox' must be
> placed inside a form tag with runat=server.]
> System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +160
> System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
> writer) +45
> System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
> writer) +22
> System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +22
> System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
> ControlAdapter adapter) +61
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapt
er
> adapter) +302
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
> System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +167
> System.Web.UI.Page.Render(HtmlTextWriter writer) +32
> System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
> ControlAdapter adapter) +61
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapt
er
> adapter) +302
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6607
>
>
> ----
--
> Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NE
T
> Version:2.0.40607.16
> Here is the source code:
> <script runat="server">
> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
> End Sub
> Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
> System.EventArgs)
> End Sub
> Sub TextBox1_TextChanged1(ByVal sender As Object, ByVal e As
> System.EventArgs)
> End Sub
> </script>
> <script language="javascript" type="text/javascript" for="document"
> event="ondatasetcomplete">
> <!--
> return document_ondatasetcomplete()
> // -->
> </script>
> <script language="javascript" type="text/javascript">
> <!--
> function document_ondatasetcomplete() {
> }
> // -->
> </script>
> <span style="font-family: Tahoma; background-color: #ffffff"></span>
> <br />
> <table enableviewstate="true">
> <tr>
> <td style="width: 325px">
> <asp:label id="Label1" runat="server" text="1. What's your
> favorite pet's name ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px">
>
> </td>
> </tr>
> <tr>
> <td style="width: 325px; height: 21px">
> <asp:label id="Label2" runat="server" text="2. What's your
> mother's birthday ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px; height: 21px">
> </td>
> </tr>
> <tr>
> <td style="width: 325px">
> <asp:label id="Label3" runat="server" text="3. What's your
> father's first name ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px">
> </td>
> </tr>
> </table>
> <br />
> <asp:textbox id="TextBox1" runat="server"></asp:textbox>
Hi
Put your TextBox Control inside the Form tag with the property runat =
server like this :
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</form>
Posted Via mcse.ms Premium Usenet Newsgroup Services
----
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----
http://www.mcse.ms
i have this problem too...
sometimes the code is deleted or isnt added correctly!
is that a bug of VS2005?
Posted Via mcse.ms Premium Usenet Newsgroup Services
----
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----
http://www.mcse.ms

Newbie:Simple textbox causing this error ?

In VS 2005, I attempt to build my VB (.aspx) application:
I simply drag and drop a Label text and a "textbox".

When I hit F5, I get the error below. Obviously it is being caused by
something missing the in the 'textbox' property. What's wrong ?
Server Error in '/P2' Application.
------------------------

Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with
runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Control 'TextBox1' of type
'TextBox' must be placed inside a form tag with runat=server.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Control 'TextBox1' of type 'TextBox' must be
placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Con trol control) +160
System.Web.UI.WebControls.TextBox.AddAttributesToR ender(HtmlTextWriter
writer) +45
System.Web.UI.WebControls.WebControl.RenderBeginTa g(HtmlTextWriter
writer) +22
System.Web.UI.WebControls.TextBox.Render(HtmlTextW riter writer) +22
System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter writer,
ControlAdapter adapter) +61
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
adapter) +302
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +167
System.Web.UI.Page.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter writer,
ControlAdapter adapter) +61
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
adapter) +302
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6607

------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NET
Version:2.0.40607.16

Here is the source code:
<script runat="server"
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

End Sub

Sub TextBox1_TextChanged1(ByVal sender As Object, ByVal e As
System.EventArgs)

End Sub
</script>
<script language="javascript" type="text/javascript" for="document"
event="ondatasetcomplete">
<!--
return document_ondatasetcomplete()
// -->
</script
<script language="javascript" type="text/javascript">
<!--

function document_ondatasetcomplete() {

}

// -->
</script>
<span style="font-family: Tahoma; background-color: #ffffff"></span>
<br />
<table enableviewstate="true">
<tr>
<td style="width: 325px">
<asp:label id="Label1" runat="server" text="1. What's your
favorite pet's name ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px">

</td>
</tr>
<tr>
<td style="width: 325px; height: 21px">
<asp:label id="Label2" runat="server" text="2. What's your
mother's birthday ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px; height: 21px">
</td>
</tr>
<tr>
<td style="width: 325px">
<asp:label id="Label3" runat="server" text="3. What's your
father's first name ?" width="311px" height="19px"></asp:label>
</td>
<td style="width: 455px">
</td>
</tr>
</table>
<br />
<asp:textbox id="TextBox1" runat="server"></asp:textboxGo at design mode of your form, click html view and ensure that
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
control is within <form> tag
you cannot place an asp control outside the <form> tag

"Mr. Magoo" <maggo@.nospasm.com> wrote in message news:<e3bTJqFJFHA.904@.tk2msftngp13.phx.gbl>...
> In VS 2005, I attempt to build my VB (.aspx) application:
> I simply drag and drop a Label text and a "textbox".
> When I hit F5, I get the error below. Obviously it is being caused by
> something missing the in the 'textbox' property. What's wrong ?
> Server Error in '/P2' Application.
> ------------------------
> Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with
> runat=server.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Web.HttpException: Control 'TextBox1' of type
> 'TextBox' must be placed inside a form tag with runat=server.
> Source Error:
> An unhandled exception was generated during the execution of the current web
> request. Information regarding the origin and location of the exception can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [HttpException (0x80004005): Control 'TextBox1' of type 'TextBox' must be
> placed inside a form tag with runat=server.]
> System.Web.UI.Page.VerifyRenderingInServerForm(Con trol control) +160
> System.Web.UI.WebControls.TextBox.AddAttributesToR ender(HtmlTextWriter
> writer) +45
> System.Web.UI.WebControls.WebControl.RenderBeginTa g(HtmlTextWriter
> writer) +22
> System.Web.UI.WebControls.TextBox.Render(HtmlTextW riter writer) +22
> System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter writer,
> ControlAdapter adapter) +61
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
> adapter) +302
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
> System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +167
> System.Web.UI.Page.Render(HtmlTextWriter writer) +32
> System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter writer,
> ControlAdapter adapter) +61
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
> adapter) +302
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +31
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6607
>
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NET
> Version:2.0.40607.16
> Here is the source code:
> <script runat="server">
> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
> End Sub
> Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
> System.EventArgs)
> End Sub
> Sub TextBox1_TextChanged1(ByVal sender As Object, ByVal e As
> System.EventArgs)
> End Sub
> </script>
> <script language="javascript" type="text/javascript" for="document"
> event="ondatasetcomplete">
> <!--
> return document_ondatasetcomplete()
> // -->
> </script>
> <script language="javascript" type="text/javascript">
> <!--
> function document_ondatasetcomplete() {
> }
> // -->
> </script>
> <span style="font-family: Tahoma; background-color: #ffffff"></span>
> <br />
> <table enableviewstate="true">
> <tr>
> <td style="width: 325px">
> <asp:label id="Label1" runat="server" text="1. What's your
> favorite pet's name ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px">
>
> </td>
> </tr>
> <tr>
> <td style="width: 325px; height: 21px">
> <asp:label id="Label2" runat="server" text="2. What's your
> mother's birthday ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px; height: 21px">
> </td>
> </tr>
> <tr>
> <td style="width: 325px">
> <asp:label id="Label3" runat="server" text="3. What's your
> father's first name ?" width="311px" height="19px"></asp:label>
> </td>
> <td style="width: 455px">
> </td>
> </tr>
> </table>
> <br />
> <asp:textbox id="TextBox1" runat="server"></asp:textbox>
Hi
Put your TextBox Control inside the Form tag with the property runat =
server like this :

<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</form
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
i have this problem too...
sometimes the code is deleted or isnt added correctly!
is that a bug of VS2005?

Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com