Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, March 29, 2012

Newbie: How safe is source code?

Hi

I am a complete newbie and am contemplating moving to asp.net from asp. How
protected is an asp.net web site source code should it be delivered to a
client?

Thanks

RegardsMy opinion:

If your concern is about protecting access to the code itself, then ASP.NET
source is much safer than classic ASP, because the deliverable is actually a
set of compiled .dll's, rather than a set of vbscript files.

However, you should be aware that it is notoriously easy to decompile a .NET
assembly into very clean source code. If this worries you, you should
consider using an obfuscator to "scramble" the dll code so that decompiling
either doesn't work or doesn't work very well.

-Michael

"John" <john@.nospam.infovis.co.uk> wrote in message
news:Oo1BKKIpDHA.2732@.TK2MSFTNGP11.phx.gbl...
> Hi
> I am a complete newbie and am contemplating moving to asp.net from asp.
How
> protected is an asp.net web site source code should it be delivered to a
> client?
> Thanks
> Regards
Hi John,

You should obfuscate your ASP.NET with Dotfuscator (a .NET
obfuscator).
A lite version is included inside VS.NET 2003 under the tools menu.
This will make reverse engineered code harder to understand.

If you want more protection that significantly hinders reverse
engineering by crashing or stopping decompilers and support look at
Dotfuscator Professional Edition.

For more info: www.preemptive.com/dotfuscator

Best Regards,
Dotfuscator Team

> "John" <john@.nospam.infovis.co.uk>
> > Hi
> > I am a complete newbie and am contemplating moving to asp.net from asp.
> How
> > protected is an asp.net web site source code should it be delivered to a
> > client?
I agree. But what about 'Whidbey' (new VS 2004)? I think we going
back to no code-behind'.

-----------------------
http://www.naptaxes.com/AAJ/
[AllAmericanJobs - Searching jobs from your desktop and automatically
sends resume.]
Even with 'no code behind' isn't the result still .NET code which can be decompiled?

> I agree. But what about 'Whidbey' (new VS 2004)? I think we going
> back to ?no code-behind'.

Newbie: How to duplicate a webform (including code) - I'm confused.

Hi there,
I am sure there is a very simple answer to this question. But how does one
duplicate a webform in ASP.net? E.g. I have a webform that has standard
basic functionality for my whole web application (e.g. a navigation bar and
general layout). I want to copy this form many times as it is the template
for each page within my application.
However, when I use "save as" and save the webform as a different name,
things do not go as planned. Also I want all the underlying code to be
copied as well (e.g. so if I use a link button, on my first page, I want the
underlying code for that button to also copy through to the duplicate page).
So how is this achieved?
I'm probably going to be told there is a better way of having a template
page as well. This information will be useful as well, but for the time
being, duplicating manually a template page will do fine.
Kind regards
Dave.Dave, in ASP.NET 1.x, there's not a real easy way to do this. There are
Master Pages - http://aspnet.4guysfromrolla.com/articles/040704-1.aspx -
but these have poor tool support in VS.NET 2002/2003.
Fortunately this becomes much less of a pain with ASP.NET 2.0 and Visual
Studio 2005... but for the time being, it's not as easy as it *should*
be. But do check out Master Pages in ASP.NET 1.x, it's better than just
copying and pasting code around on each page...
Dave Smithz wrote:
> I am sure there is a very simple answer to this question. But how does one
> duplicate a webform in ASP.net? E.g. I have a webform that has standard
> basic functionality for my whole web application (e.g. a navigation bar an
d
> general layout). I want to copy this form many times as it is the template
> for each page within my application.
> However, when I use "save as" and save the webform as a different name,
> things do not go as planned. Also I want all the underlying code to be
> copied as well (e.g. so if I use a link button, on my first page, I want t
he
> underlying code for that button to also copy through to the duplicate page
).
> So how is this achieved?
> I'm probably going to be told there is a better way of having a template
> page as well. This information will be useful as well, but for the time
> being, duplicating manually a template page will do fine.
Scott Mitchell
mitchell@.4guysfromrolla.com
http://www.4GuysFromRolla.com
* When you think ASP.NET, think 4GuysFromRolla.com!
"Scott Mitchell [MVP]" <mitchell@.4guysfromrolla.com> wrote in message
news:h6Dfd.10379> Dave, in ASP.NET 1.x, there's not a real easy way to do
this. There are
> Master Pages - http://aspnet.4guysfromrolla.com/articles/040704-1.aspx -
> but these have poor tool support in VS.NET 2002/2003.
OK So not such a stupid question then. But now I probably have one. I've
knocked together a basic ASP.net website to show someone. But I wnat to show
them without having to run Visual Studio.net. Currently I press f5 to run
the web application, but I want to be able to just go to a URL without
having to run VS first.
How do I do this?
Kind regards
Dave
"Dave Smithz" <SPAM FREE WORLD> wrote in message
news:417fb0f2$1@.news1.homechoice.co.uk...
> "Scott Mitchell [MVP]" <mitchell@.4guysfromrolla.com> wrote in message
> news:h6Dfd.10379> Dave, in ASP.NET 1.x, there's not a real easy way to do
> this. There are
> OK So not such a stupid question then. But now I probably have one. I've
> knocked together a basic ASP.net website to show someone. But I wnat to
> show
> them without having to run Visual Studio.net. Currently I press f5 to run
> the web application, but I want to be able to just go to a URL without
> having to run VS first.
> How do I do this?
What happens if you just go to the URL?
--
John Saunders
"John Saunders" <johnwsaundersiii@.hotmail.com> wrote in message >
> What happens if you just go to the URL?
> --
> John Saunders
errrr, it seems to work now. But I tell you it didn't before! ;)
Cheers

Newbie: How to duplicate a webform (including code) - Im confused.

Hi there,

I am sure there is a very simple answer to this question. But how does one
duplicate a webform in ASP.net? E.g. I have a webform that has standard
basic functionality for my whole web application (e.g. a navigation bar and
general layout). I want to copy this form many times as it is the template
for each page within my application.
However, when I use "save as" and save the webform as a different name,
things do not go as planned. Also I want all the underlying code to be
copied as well (e.g. so if I use a link button, on my first page, I want the
underlying code for that button to also copy through to the duplicate page).

So how is this achieved?

I'm probably going to be told there is a better way of having a template
page as well. This information will be useful as well, but for the time
being, duplicating manually a template page will do fine.

Kind regards

Dave.Dave, in ASP.NET 1.x, there's not a real easy way to do this. There are
Master Pages - http://aspnet.4guysfromrolla.com/articles/040704-1.aspx -
but these have poor tool support in VS.NET 2002/2003.

Fortunately this becomes much less of a pain with ASP.NET 2.0 and Visual
Studio 2005... but for the time being, it's not as easy as it *should*
be. But do check out Master Pages in ASP.NET 1.x, it's better than just
copying and pasting code around on each page...

Dave Smithz wrote:
> I am sure there is a very simple answer to this question. But how does one
> duplicate a webform in ASP.net? E.g. I have a webform that has standard
> basic functionality for my whole web application (e.g. a navigation bar and
> general layout). I want to copy this form many times as it is the template
> for each page within my application.
> However, when I use "save as" and save the webform as a different name,
> things do not go as planned. Also I want all the underlying code to be
> copied as well (e.g. so if I use a link button, on my first page, I want the
> underlying code for that button to also copy through to the duplicate page).
> So how is this achieved?
> I'm probably going to be told there is a better way of having a template
> page as well. This information will be useful as well, but for the time
> being, duplicating manually a template page will do fine.

--

Scott Mitchell
mitchell@.4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
"Scott Mitchell [MVP]" <mitchell@.4guysfromrolla.com> wrote in message
news:h6Dfd.10379> Dave, in ASP.NET 1.x, there's not a real easy way to do
this. There are
> Master Pages - http://aspnet.4guysfromrolla.com/articles/040704-1.aspx -
> but these have poor tool support in VS.NET 2002/2003.

OK So not such a stupid question then. But now I probably have one. I've
knocked together a basic ASP.net website to show someone. But I wnat to show
them without having to run Visual Studio.net. Currently I press f5 to run
the web application, but I want to be able to just go to a URL without
having to run VS first.

How do I do this?

Kind regards

Dave
"John Saunders" <johnwsaundersiii@.hotmail.com> wrote in message >
> What happens if you just go to the URL?
> --
> John Saunders

errrr, it seems to work now. But I tell you it didn't before! ;)

Cheers
"Dave Smithz" <SPAM FREE WORLD> wrote in message
news:417fb0f2$1@.news1.homechoice.co.uk...
> "Scott Mitchell [MVP]" <mitchell@.4guysfromrolla.com> wrote in message
> news:h6Dfd.10379> Dave, in ASP.NET 1.x, there's not a real easy way to do
> this. There are
>> Master Pages - http://aspnet.4guysfromrolla.com/articles/040704-1.aspx -
>> but these have poor tool support in VS.NET 2002/2003.
> OK So not such a stupid question then. But now I probably have one. I've
> knocked together a basic ASP.net website to show someone. But I wnat to
> show
> them without having to run Visual Studio.net. Currently I press f5 to run
> the web application, but I want to be able to just go to a URL without
> having to run VS first.
> How do I do this?

What happens if you just go to the URL?
--
John Saunders

newbie: how to print stuff at the shell using C# while at programming in asp.net

Hi, I made myself a componment, so it can talk to the database.
I want to able to see the certain value within the code itself. And I'm unable to use asp:label control.
Is there's any way I can print stuff on the shell so I can keep track of where I'm at with my varable?
I tried Console.Write(temp); but it didn't seem to work :(
TIA
Use one of the System.Diagnostics.Debug.Writexxx() methods. These will appear in the Output Window in Visual Studio as you run the site under the debugger.
Alternatively, use the HttpContext.Current.Trace.Write() method, and this will put output into the ASP.NET Trace, which you can either see on the page or via the trace.axd handler.

Thank you very much DMW, System.Diagnostics.Debug.Writexxx() is useful

case close

newbie: I don't want my .aspx and .cs files to have the source viewable by the client

I'm creating a C# .net project, for a client. However they only have the
right to the binaries, not the source code. Is there a way to compile it so
that I just give them dll's? or do they need the .aspx pages. I read
somewhere that I could probably make assemblies (excuse my bad terminology)
of the source code, but that it is quiet easy to disassemble the assemblies,
so that does not seem to afford read protection.
or am I just all over nothing!
thanksYou need to give them the ASPX pages and the compiled DLLs, but you do not
need to give them the .CS source code files.
If they are unethical they could decombile the DLLs to get a rough
approximation of the source code, but you can thwart them with an
Obfuscator.
Visual Studio 2003 has a basic built in obfuscator, but for 2002 you'll need
a 3rd party solution.
Here's more information on obfuscators:
http://www.abderaware.com/WhitePapers/Obfuscator.htm
http://www.preemptive.com/dotfuscator/index.html
http://www.devx.com/SummitDays/Article/11351
http://www.lesser-software.com/ilobf.htm
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Seth Broomer" <asdf@.asdsd.com> wrote in message
news:eWLgn06jEHA.1656@.TK2MSFTNGP09.phx.gbl...
> I'm creating a C# .net project, for a client. However they only have the
> right to the binaries, not the source code. Is there a way to compile it
> so
> that I just give them dll's? or do they need the .aspx pages. I read
> somewhere that I could probably make assemblies (excuse my bad
> terminology)
> of the source code, but that it is quiet easy to disassemble the
> assemblies,
> so that does not seem to afford read protection.
> or am I just all over nothing!
> thanks
>

newbie: I dont want my .aspx and .cs files to have the source viewable by the client

I'm creating a C# .net project, for a client. However they only have the
right to the binaries, not the source code. Is there a way to compile it so
that I just give them dll's? or do they need the .aspx pages. I read
somewhere that I could probably make assemblies (excuse my bad terminology)
of the source code, but that it is quiet easy to disassemble the assemblies,
so that does not seem to afford read protection.

or am I just all confused over nothing!

thanksYou need to give them the ASPX pages and the compiled DLLs, but you do not
need to give them the .CS source code files.
If they are unethical they could decombile the DLLs to get a rough
approximation of the source code, but you can thwart them with an
Obfuscator.
Visual Studio 2003 has a basic built in obfuscator, but for 2002 you'll need
a 3rd party solution.

Here's more information on obfuscators:
http://www.abderaware.com/WhitePapers/Obfuscator.htm
http://www.preemptive.com/dotfuscator/index.html
http://www.devx.com/SummitDays/Article/11351
http://www.lesser-software.com/ilobf.htm

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Seth Broomer" <asdf@.asdsd.com> wrote in message
news:eWLgn06jEHA.1656@.TK2MSFTNGP09.phx.gbl...
> I'm creating a C# .net project, for a client. However they only have the
> right to the binaries, not the source code. Is there a way to compile it
> so
> that I just give them dll's? or do they need the .aspx pages. I read
> somewhere that I could probably make assemblies (excuse my bad
> terminology)
> of the source code, but that it is quiet easy to disassemble the
> assemblies,
> so that does not seem to afford read protection.
> or am I just all confused over nothing!
> thanks
FYI - Just remember there are Deobfuscator out there. But at least you are
taking some sort of measure to secure the DLLs.

"Steve C. Orr [MVP, MCSD]" wrote:

> You need to give them the ASPX pages and the compiled DLLs, but you do not
> need to give them the .CS source code files.
> If they are unethical they could decombile the DLLs to get a rough
> approximation of the source code, but you can thwart them with an
> Obfuscator.
> Visual Studio 2003 has a basic built in obfuscator, but for 2002 you'll need
> a 3rd party solution.
> Here's more information on obfuscators:
> http://www.abderaware.com/WhitePapers/Obfuscator.htm
> http://www.preemptive.com/dotfuscator/index.html
> http://www.devx.com/SummitDays/Article/11351
> http://www.lesser-software.com/ilobf.htm
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "Seth Broomer" <asdf@.asdsd.com> wrote in message
> news:eWLgn06jEHA.1656@.TK2MSFTNGP09.phx.gbl...
> > I'm creating a C# .net project, for a client. However they only have the
> > right to the binaries, not the source code. Is there a way to compile it
> > so
> > that I just give them dll's? or do they need the .aspx pages. I read
> > somewhere that I could probably make assemblies (excuse my bad
> > terminology)
> > of the source code, but that it is quiet easy to disassemble the
> > assemblies,
> > so that does not seem to afford read protection.
> > or am I just all confused over nothing!
> > thanks
>

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
>

Newbie: Is it possible to set <body> attributes via code behind?

I'm sure it's possible, but it hasn't occurred to me "how" to set the values
of the <body> tag via code-behind. I am currently setting the onload event i
n
the body tag of an ASP.NET web form using old-fashion asp type <%.. code...
%> blocks.
This "spaghetti-scripting" is difficult to manage, and is essentially a
hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
further causes problems when i try to wire events.
I tried, for example, to embbed an <asp:label /> and other controls in the
<body> tag, but VS.NET doesn't let me (probably for good reason too).
Anyone have ideas?
Thanks,<body id="body" runat="server">
codebehind:
protected body as HtmlGenericControl
Page_Load..
body.Attributes.Add("onLoad", "alert('Karl for the win!');")
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
Give the body an id and a runat=server. For example <body id=body1
runat=server>. In codebehind (vb) put
Protected body1 as htmlgenericcontrol in your declarations. Then you can set
any attribute that you can set in html. Here is an example of setting the
onload attribute.
body1.attributes("onload") ="java script:doSomething();return false;"
Mike
throw a RUNAT=SERVER in it and declare it in the codebehind. It should
work...
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values
> of the <body> tag via code-behind. I am currently setting the onload event
> in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
> code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
Mark <body runat=server id=_body> then manually in your codebehind add:
protected System.Web.UI.HtmlControls.HtmlGenericControl _body;
And then you should be abe to use _body.Attributes.Add() and any other API
to modify the element.
-Brock
DevelopMentor
http://staff.develop.com/ballen

> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values of the <body> tag via code-behind. I am currently setting the
> onload event in the body tag of an ASP.NET web form using old-fashion
> asp type <%.. code... %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially
> a hack. And, i cannot view the HTML in DESIGN view, only CODE view.
> Which further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in
> the <body> tag, but VS.NET doesn't let me (probably for good reason
> too).
> Anyone have ideas?
> Thanks,
>
"Karl for the win!" ? hehehehe I like it! :}
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23AhK3h8LFHA.2772@.TK2MSFTNGP12.phx.gbl...
> <body id="body" runat="server">
> codebehind:
> protected body as HtmlGenericControl
> Page_Load..
> body.Attributes.Add("onLoad", "alert('Karl for the win!');")
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "charliewest" <charliewest@.discussions.microsoft.com> wrote in message
> news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> values
> in
> code...
>

Newbie: Is it possible to set <body> attributes via code behind?

I'm sure it's possible, but it hasn't occurred to me "how" to set the values
of the <body> tag via code-behind. I am currently setting the onload event in
the body tag of an ASP.NET web form using old-fashion asp type <%.. code...
%> blocks.

This "spaghetti-scripting" is difficult to manage, and is essentially a
hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
further causes problems when i try to wire events.

I tried, for example, to embbed an <asp:label /> and other controls in the
<body> tag, but VS.NET doesn't let me (probably for good reason too).

Anyone have ideas?

Thanks,<body id="body" runat="server"
codebehind:

protected body as HtmlGenericControl

Page_Load..
body.Attributes.Add("onLoad", "alert('Karl for the win!');")

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,

Give the body an id and a runat=server. For example <body id=body1
runat=server>. In codebehind (vb) put
Protected body1 as htmlgenericcontrol in your declarations. Then you can set
any attribute that you can set in html. Here is an example of setting the
onload attribute.

body1.attributes("onload") ="javascript:doSomething();return false;"

Mike
throw a RUNAT=SERVER in it and declare it in the codebehind. It should
work...

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values
> of the <body> tag via code-behind. I am currently setting the onload event
> in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
> code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
Mark <body runat=server id=_body> then manually in your codebehind add:

protected System.Web.UI.HtmlControls.HtmlGenericControl _body;

And then you should be abe to use _body.Attributes.Add() and any other API
to modify the element.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values of the <body> tag via code-behind. I am currently setting the
> onload event in the body tag of an ASP.NET web form using old-fashion
> asp type <%.. code... %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially
> a hack. And, i cannot view the HTML in DESIGN view, only CODE view.
> Which further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in
> the <body> tag, but VS.NET doesn't let me (probably for good reason
> too).
> Anyone have ideas?
> Thanks,
"Karl for the win!" ? hehehehe I like it! :}

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23AhK3h8LFHA.2772@.TK2MSFTNGP12.phx.gbl...
> <body id="body" runat="server">
> codebehind:
> protected body as HtmlGenericControl
> Page_Load..
> body.Attributes.Add("onLoad", "alert('Karl for the win!');")
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "charliewest" <charliewest@.discussions.microsoft.com> wrote in message
> news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
>> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values
>> of the <body> tag via code-behind. I am currently setting the onload
>> event
> in
>> the body tag of an ASP.NET web form using old-fashion asp type <%..
> code...
>> %> blocks.
>>
>> This "spaghetti-scripting" is difficult to manage, and is essentially a
>> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
>> further causes problems when i try to wire events.
>>
>> I tried, for example, to embbed an <asp:label /> and other controls in
>> the
>> <body> tag, but VS.NET doesn't let me (probably for good reason too).
>>
>> Anyone have ideas?
>>
>> Thanks,

Newbie: Javascript help

What js code is required to automatically submit a page to the server when a
user enters a given character (say "?") into a textbox server control please?

Thank youIn the .aspx page (did not check it running):

<head>
...
function checkKey(){
if (window.event.keyCode==63)
myForm.submit();
else
return true;
}
...
</head>
<body>
<form id=myForm ...?>
...
<asp:textbox ... onkeypress="return checkKey();" ... />
...
</form></body
Eliyahu

"MikeH" <MikeH@.community.nospam> wrote in message
news:BE91A000-8D92-448E-9B03-CC531DF85F8D@.microsoft.com...
> What js code is required to automatically submit a page to the server when
a
> user enters a given character (say "?") into a textbox server control
please?
> Thank you

newbie: ItemDataBound and XPath

hey

asp.net 2.0

I have a DataList which has a XmlDataSource as its data source.

This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs
e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}

Any suggestion how this should be done in a ItemDataBound event?

Jeff"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eCAL$KttGHA.2160@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I have a DataList which has a XmlDataSource as its data source.
>
This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}
>
Any suggestion how this should be done in a ItemDataBound event?
>
Jeff
>


Jeff look at this sample here at:-
http://www.msdner.com/forum/thread467894.html
Patrick

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eCAL$KttGHA.2160@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I have a DataList which has a XmlDataSource as its data source.
>
This code crash because I use XPath in the ItemDataBound event:
protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
Label label = (Label)e.Item.FindControl("lblTitle");
label.Text = XPath("title").ToString();
label = (Label)e.Item.FindControl("lblStory");
label.Text = XPath("description").ToString();
}
>
Any suggestion how this should be done in a ItemDataBound event?
>
Jeff
>

Newbie: Issue with postback

I think I may not understand postback. I thought when you first view page this is not postback, but then it is i.e everytime I hit F5.

This code doesn't appear to work (it always states that the page is not a postback:

<%@dotnet.itags.org.Page Language="VB"%>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
If Page.IsPostBack Then
Response.write("postback")
Else
Response.write("start")
End If
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
<html>
<head>
<title>Testing Postback</title>
</head
<body
<form action="postback.aspx">
<input type="submit" name="sub" value="go"/>
</form
</body>
</html
Also, isn't the source of the page supposed to show the encrypted viewstate hidden field. On my page this is not present.

I would be grateful for any tips on where I'm going wrong.

MHitting F5 or refresh DOES NOT cause a postback. If you click a button on the page, THEN you will get a postback.

Monday, March 26, 2012

newbie: My code crashes

hey

asp.net 2.0

I'm trying to make a webpage that shows a list of pictures. When the user
clicks on a picture, the user is redirected to another page in my website.
The links are generated at runtime

My code crashes during runtime because of a variable in the ItemDataBound
event is null. Below I show my problem code and maybe some of you could give
me a suggestion to what should do to fix this...

<td rowspan="2"><a id="LinkToProfile" href="http://links.10026.com/?link="><asp:Image ID="MemberPhoto"
runat="server" ImageAlign="Left" /></a></td>

System.Web.UI.HtmlControls.HtmlAnchor link = null;
link =
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");
link.HRef = "../test.aspx?id=" + subscriber.UserName;

My code crashes because the variable "link" is null after this line "link =
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");"

Any suggestions that may solve this problem are very welcome :-)

JeffThat is because there is no control with the id "LinkToProfile". You
have to put runat="server" in the tag to make it a server control.

Jeff wrote:

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I'm trying to make a webpage that shows a list of pictures. When the user
clicks on a picture, the user is redirected to another page in my website.
The links are generated at runtime
>
My code crashes during runtime because of a variable in the ItemDataBound
event is null. Below I show my problem code and maybe some of you could give
me a suggestion to what should do to fix this...
>
>
<td rowspan="2"><a id="LinkToProfile" href="http://links.10026.com/?link="><asp:Image ID="MemberPhoto"
runat="server" ImageAlign="Left" /></a></td>
>
System.Web.UI.HtmlControls.HtmlAnchor link = null;
link =
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");
link.HRef = "../test.aspx?id=" + subscriber.UserName;
>
My code crashes because the variable "link" is null after this line "link =
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");"
>
Any suggestions that may solve this problem are very welcome :-)
>
Jeff
>
>


Why not dynamically generated ImageButtons and set the image and postbackUrl
on the control to do what you desire. You can then have complete control
without a lot of code and use a control that is designed to do both of the
tasks you desire.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23Pma5OmoGHA.5104@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I'm trying to make a webpage that shows a list of pictures. When the user
clicks on a picture, the user is redirected to another page in my website.
The links are generated at runtime
>
My code crashes during runtime because of a variable in the ItemDataBound
event is null. Below I show my problem code and maybe some of you could
give me a suggestion to what should do to fix this...
>
>
<td rowspan="2"><a id="LinkToProfile" href="http://links.10026.com/?link="><asp:Image ID="MemberPhoto"
runat="server" ImageAlign="Left" /></a></td>
>
System.Web.UI.HtmlControls.HtmlAnchor link = null;
link =
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");
link.HRef = "../test.aspx?id=" + subscriber.UserName;
>
My code crashes because the variable "link" is null after this line "link
=
(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");"
>
Any suggestions that may solve this problem are very welcome :-)
>
Jeff
>
>


Thanks for the advice, I will try it.

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamMwrote in
message news:Oax8NlqoGHA.4960@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Why not dynamically generated ImageButtons and set the image and
postbackUrl on the control to do what you desire. You can then have
complete control without a lot of code and use a control that is designed
to do both of the tasks you desire.
>
--
Gregory A. Beamer
>
*************************************************
Think Outside the Box!
*************************************************
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23Pma5OmoGHA.5104@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>I'm trying to make a webpage that shows a list of pictures. When the user
>clicks on a picture, the user is redirected to another page in my
>website. The links are generated at runtime
>>
>My code crashes during runtime because of a variable in the ItemDataBound
>event is null. Below I show my problem code and maybe some of you could
>give me a suggestion to what should do to fix this...
>>
>>
><td rowspan="2"><a id="LinkToProfile" href="http://links.10026.com/?link="><asp:Image ID="MemberPhoto"
>runat="server" ImageAlign="Left" /></a></td>
>>
>System.Web.UI.HtmlControls.HtmlAnchor link = null;
>link =
>(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");
>link.HRef = "../test.aspx?id=" + subscriber.UserName;
>>
>My code crashes because the variable "link" is null after this line "link
>=
>(System.Web.UI.HtmlControls.HtmlAnchor)e.Item.Find Control("LinkToProfile");"
>>
>Any suggestions that may solve this problem are very welcome :-)
>>
>Jeff
>>
>>


>
>

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 css/html code

hey
asp.net 2.0
Please, I need some help with the layout of my webpage. this link shows my
problem: http://home.online.no/~au-holme/pub.../divtrouble.PNG
Instead of fieldname and value are displayed like this:
<FIELDNAME>
<FIELDVALUE>
I want fieldname & fieldvalue to be displayed on the same line:
<FIELDNAME> <FIELDVALUE>
This is my html:
<ul class="settings">
<li>Site preference
<ul class="subsettings">
<li><div class="setting">
<div class="fieldname">Newsletter:</div>
<div class="fieldvalue">
<asp:DropDownList ID="ddlSubscriptions"
runat="server">
<asp:ListItem Text="No subscription"
Value="None" Selected="true"></asp:ListItem>
<asp:ListItem Text="Subscribe to plain-text
vesion" Value="PlainText"></asp:ListItem>
<asp:ListItem Text="Subscribe to HTML version"
Value="Html"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
</li>
<li><div class="fieldname">Language:</div>
<asp:DropDownList ID="ddlLanguages" runat="server">
<asp:ListItem Text="English" Value="en-US"
Selected="True"></asp:ListItem>
<asp:ListItem Text="Norwegian"
Value="no-NO"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</li>
<li>Personal details
</li>
</ul>
This is my css:
.settings, .subsettings
{
list-style:none;
}
.settings li
{
font-family:Arial;
font-size:xx-large;
}
.subsettings li
{
font-family:Arial;
font-size:medium;
}
.subsettings li .fieldname
{
width:180px;
border:solid 2px yellow;
}
.subsettings li .fieldvalue
{
width:220px;
border:solid 2px cyan;
}
.setting
{
width:500px;
border:solid 2px red;
}<div>'s are a block element, meaning they go on their own line. use a
<span> which is an inline element instead.
-- bruce (sqlwork.com)
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:OOemtbo3GHA.3812@.TK2MSFTNGP06.phx.gbl...
> hey
> asp.net 2.0
> Please, I need some help with the layout of my webpage. this link shows my
> problem: http://home.online.no/~au-holme/pub.../divtrouble.PNG
> Instead of fieldname and value are displayed like this:
> <FIELDNAME>
> <FIELDVALUE>
> I want fieldname & fieldvalue to be displayed on the same line:
> <FIELDNAME> <FIELDVALUE>
> This is my html:
> <ul class="settings">
> <li>Site preference
> <ul class="subsettings">
> <li><div class="setting">
> <div class="fieldname">Newsletter:</div>
> <div class="fieldvalue">
> <asp:DropDownList ID="ddlSubscriptions"
> runat="server">
> <asp:ListItem Text="No subscription"
> Value="None" Selected="true"></asp:ListItem>
> <asp:ListItem Text="Subscribe to plain-text
> vesion" Value="PlainText"></asp:ListItem>
> <asp:ListItem Text="Subscribe to HTML version"
> Value="Html"></asp:ListItem>
> </asp:DropDownList>
> </div>
> </div>
> </li>
> <li><div class="fieldname">Language:</div>
> <asp:DropDownList ID="ddlLanguages" runat="server">
> <asp:ListItem Text="English" Value="en-US"
> Selected="True"></asp:ListItem>
> <asp:ListItem Text="Norwegian"
> Value="no-NO"></asp:ListItem>
> </asp:DropDownList>
> </li>
> </ul>
> </li>
> <li>Personal details
> </li>
> </ul>
> This is my css:
> .settings, .subsettings
> {
> list-style:none;
> }
> .settings li
> {
> font-family:Arial;
> font-size:xx-large;
> }
> .subsettings li
> {
> font-family:Arial;
> font-size:medium;
> }
> .subsettings li .fieldname
> {
> width:180px;
> border:solid 2px yellow;
> }
> .subsettings li .fieldvalue
> {
> width:220px;
> border:solid 2px cyan;
> }
> .setting
> {
> width:500px;
> border:solid 2px red;
> }
>

newbie: need help with this css/html code

hey

asp.net 2.0

Please, I need some help with the layout of my webpage. this link shows my
problem: http://home.online.no/~au-holme/pub.../divtrouble.PNG
Instead of fieldname and value are displayed like this:
<FIELDNAME>
<FIELDVALUE>

I want fieldname & fieldvalue to be displayed on the same line:
<FIELDNAME<FIELDVALUE>

This is my html:
<ul class="settings">
<li>Site preference
<ul class="subsettings">
<li><div class="setting">
<div class="fieldname">Newsletter:</div>
<div class="fieldvalue">
<asp:DropDownList ID="ddlSubscriptions"
runat="server">
<asp:ListItem Text="No subscription"
Value="None" Selected="true"></asp:ListItem>
<asp:ListItem Text="Subscribe to plain-text
vesion" Value="PlainText"></asp:ListItem>
<asp:ListItem Text="Subscribe to HTML version"
Value="Html"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
</li>
<li><div class="fieldname">Language:</div>
<asp:DropDownList ID="ddlLanguages" runat="server">
<asp:ListItem Text="English" Value="en-US"
Selected="True"></asp:ListItem>
<asp:ListItem Text="Norwegian"
Value="no-NO"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</li>
<li>Personal details
</li>
</ul>

This is my css:
..settings, .subsettings
{
list-style:none;
}

..settings li
{
font-family:Arial;
font-size:xx-large;
}

..subsettings li
{
font-family:Arial;
font-size:medium;
}

..subsettings li .fieldname
{
width:180px;
border:solid 2px yellow;
}

..subsettings li .fieldvalue
{
width:220px;
border:solid 2px cyan;
}

..setting
{
width:500px;
border:solid 2px red;
}<div>'s are a block element, meaning they go on their own line. use a
<spanwhich is an inline element instead.

-- bruce (sqlwork.com)

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:OOemtbo3GHA.3812@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
Please, I need some help with the layout of my webpage. this link shows my
problem: http://home.online.no/~au-holme/pub.../divtrouble.PNG
>
Instead of fieldname and value are displayed like this:
<FIELDNAME>
<FIELDVALUE>
>
I want fieldname & fieldvalue to be displayed on the same line:
<FIELDNAME<FIELDVALUE>
>
This is my html:
<ul class="settings">
<li>Site preference
<ul class="subsettings">
<li><div class="setting">
<div class="fieldname">Newsletter:</div>
<div class="fieldvalue">
<asp:DropDownList ID="ddlSubscriptions"
runat="server">
<asp:ListItem Text="No subscription"
Value="None" Selected="true"></asp:ListItem>
<asp:ListItem Text="Subscribe to plain-text
vesion" Value="PlainText"></asp:ListItem>
<asp:ListItem Text="Subscribe to HTML version"
Value="Html"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
</li>
<li><div class="fieldname">Language:</div>
<asp:DropDownList ID="ddlLanguages" runat="server">
<asp:ListItem Text="English" Value="en-US"
Selected="True"></asp:ListItem>
<asp:ListItem Text="Norwegian"
Value="no-NO"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</li>
<li>Personal details
</li>
</ul>
>
This is my css:
.settings, .subsettings
{
list-style:none;
}
>
.settings li
{
font-family:Arial;
font-size:xx-large;
}
>
.subsettings li
{
font-family:Arial;
font-size:medium;
}
>
.subsettings li .fieldname
{
width:180px;
border:solid 2px yellow;
}
>
.subsettings li .fieldvalue
{
width:220px;
border:solid 2px cyan;
}
>
.setting
{
width:500px;
border:solid 2px red;
}
>

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
>
>

newbie: Problem with CreateUserWizard

Hey

Below is the source code of the CreateUserWizard placed on one my web pages
(asp.net 2.0).

The problem is that the AssignUserToRole method isn't triggered when
clicking on the finish button (that Images/Go.gif image).

So I'm wondering what I'm doing wrong here

******************* markup ********************
<asp:CreateUserWizard FinishDestinationPageUrl="~/Default.aspx"
ID="CreateUserWizard1"
Width="300px" runat="server"
LoginCreatedUser="false"
CreateUserButtonType="Image"
CreateUserButtonImageUrl="Images/Go.gif"
OnFinishButtonClick="AssignUserToRole">

<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<label for="Username">User name:</label>
<asp:TextBox id="Username" runat="server" />

<label for="Password">Password:</label>
<asp:TextBox id="Password" runat="server"
TextMode="Password" />

<label for="ConfirmPassword">Confirm
Password:</label>
<asp:TextBox id="ConfirmPassword" runat="server"
TextMode="Password" />

<label for="Email">Email</label>
<asp:TextBox id="Email" runat="server" />

<label for="Question">Security question:</label>
<asp:TextBox id="Question" runat="server" />

<label for="Answer">Security answer:</label>
<asp:TextBox id="Answer" runat="server" />

</ContentTemplate>
</asp:CreateUserWizardStep>

<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
<ContentTemplate>rrrr</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

***************** AssignUserToRole code **********************
protected void AssignUserToRole(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser();
user.IsApproved = false;
MailMessage mail = new MailMessage("name@dotnet.itags.org.somewhere.domain", user.Email,
"Thank you", "Hello World");
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mail);
mail.Dispose();
}

Any suggestions?I put the functionality into the CreatedUser event

Jeff

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:e7LUO45SHHA.920@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hey
>
Below is the source code of the CreateUserWizard placed on one my web
pages (asp.net 2.0).
>
The problem is that the AssignUserToRole method isn't triggered when
clicking on the finish button (that Images/Go.gif image).
>
So I'm wondering what I'm doing wrong here
>
******************* markup ********************
<asp:CreateUserWizard FinishDestinationPageUrl="~/Default.aspx"
ID="CreateUserWizard1"
Width="300px" runat="server"
LoginCreatedUser="false"
CreateUserButtonType="Image"
CreateUserButtonImageUrl="Images/Go.gif"
OnFinishButtonClick="AssignUserToRole">
>
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<label for="Username">User name:</label>
<asp:TextBox id="Username" runat="server" />
>
<label for="Password">Password:</label>
<asp:TextBox id="Password" runat="server"
TextMode="Password" />
>
<label for="ConfirmPassword">Confirm
Password:</label>
<asp:TextBox id="ConfirmPassword"
runat="server" TextMode="Password" />
>
<label for="Email">Email</label>
<asp:TextBox id="Email" runat="server" />
>
<label for="Question">Security
question:</label>
<asp:TextBox id="Question" runat="server" />
>
<label for="Answer">Security answer:</label>
<asp:TextBox id="Answer" runat="server" />
>
>
</ContentTemplate>
</asp:CreateUserWizardStep>
>
<asp:CompleteWizardStep ID="CompleteWizardStep1"
runat="server">
<ContentTemplate>rrrr</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
>
***************** AssignUserToRole code **********************
protected void AssignUserToRole(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser();
user.IsApproved = false;
MailMessage mail = new MailMessage("name@.somewhere.domain", user.Email,
"Thank you", "Hello World");
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mail);
mail.Dispose();
}
>
Any suggestions?
>
>