Thursday, March 29, 2012

Manually Clear Session Object and State Server

We are using State Server to host our session objects.
We have several applications running under IIS that will be using the State
Server.
How can one of those applications clear its Session state? If it was in
process, we could just stop and start the web app. We can not just stop and
start the State Server service because it would wipe out state for all
applications.
Thanks,
fmHi Fm,
Thanks for your posting. As for the problem you mentioned, I think there is
no buildin means for managea certain single application's session state
since the state server is run as a windows service on the server and
haven't any particular managment interface. But you may try modifying the
asp.net application's web.config to change the sessionstate mode to see
wheher this can make the stateserver session invalidated. For example,
change the Session Mode to InProc and run the applicaiton, then change it
back to StateServer Mode.
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,
I have tried tried that in the past and I just reconfirmed it that switching
the session from InProc and back to StateServer restores the values sitting
in StateServer.
A hack I tried is setting the Timeout to 1 minute. But the session has to be
idle for the original 20 minutes before this new timeout takes affect.
Quite frustrating. Seems like an even bigger hack will be required like
having an administrator drop an include file on the server that each request
will check to see if it should call Session.RemoveAll or something.
Hopefully ASP.NET and IIS6 will be more robust then the current ASP IIS5
solution for the development team that requested this requirement so they
won't need it.
Thanks,
fm
"Steven Cheng[MSFT]" wrote:

> Hi Fm,
> Thanks for your posting. As for the problem you mentioned, I think there i
s
> no buildin means for managea certain single application's session state
> since the state server is run as a windows service on the server and
> haven't any particular managment interface. But you may try modifying the
> asp.net application's web.config to change the sessionstate mode to see
> wheher this can make the stateserver session invalidated. For example,
> change the Session Mode to InProc and run the applicaiton, then change it
> back to StateServer Mode.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi Steven,
Another that came to me, can more then one instance of State Server run on a
server?
Thanks,
Fm
"Steven Cheng[MSFT]" wrote:

> Hi Fm,
> Thanks for your posting. As for the problem you mentioned, I think there i
s
> no buildin means for managea certain single application's session state
> since the state server is run as a windows service on the server and
> haven't any particular managment interface. But you may try modifying the
> asp.net application's web.config to change the sessionstate mode to see
> wheher this can make the stateserver session invalidated. For example,
> change the Session Mode to InProc and run the applicaiton, then change it
> back to StateServer Mode.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi Fm,
AS for instance of StateServer, I think only one is existing on a
StateServer machine because the asp.net statserver is run as a windows
service, you can find it in the server's service list. Thanks.
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Manually Configure site for ASP .NET 2 - Revisited

Same problem here, but with Windows XP x64 Edition. I'm trying to setup the
default DotNetNuke website and get:

Configuring web site http//localhost/DotNetNuke to ASP .NET 2.0 failed. You
may need to manually configure this site for ASP.NET 2.0 in order for you
site to run correctly.

Then I run:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i
The error indicates that IIS is in 64 bit mode, while this application is a
32 b
it application and thus not compatible.

Hmmm. Change IIS to 32 bit operation somehow? or is there an ASP problem?
Ideas?

Windows XP x64 Edition
Visual Web Developer 2005 Express Editon
Athalon 2.2Ghz cpu (don't remember which model)
2GB ram
Too much hard disk
eVGA 6xxx gs video
Current with Microsoft updates.

Tried to repair VWD install, but that didn't make any difference.

Thanks,
David

Quote:

Originally Posted by

Hi
>
I am using Visual Studio 2005 on windows XP professional (with IIS).
>
Following the walkthrough provided by help "creating web page for mobile
devices" , I have created a website , but as soon as I carry out the last
step in creating the website , as the website is being loaded in the IDE ,
I
get error message "Configuring web site http//localhost/DeviceWalkthrough
to ASP .NET 2.0 failed. You may need to manually configure this site for
ASP
.NET 2.0 in order for you site to run correctly ".
>
Could you please tell me how can I manually configure the site ?
>
>
Thank you.
>
>

Hi

Hope this link should help you.

http://aspalliance.com/groups/micro..._ASP_NET_2.aspx
Prem

"D" wrote:

Quote:

Originally Posted by

Same problem here, but with Windows XP x64 Edition. I'm trying to setup the
default DotNetNuke website and get:
>
Configuring web site http//localhost/DotNetNuke to ASP .NET 2.0 failed. You
may need to manually configure this site for ASP.NET 2.0 in order for you
site to run correctly.
>
Then I run:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i
The error indicates that IIS is in 64 bit mode, while this application is a
32 b
it application and thus not compatible.
>
Hmmm. Change IIS to 32 bit operation somehow? or is there an ASP problem?
Ideas?
>
Windows XP x64 Edition
Visual Web Developer 2005 Express Editon
Athalon 2.2Ghz cpu (don't remember which model)
2GB ram
Too much hard disk
eVGA 6xxx gs video
Current with Microsoft updates.
>
Tried to repair VWD install, but that didn't make any difference.
>
Thanks,
David
>

Quote:

Originally Posted by

Hi

I am using Visual Studio 2005 on windows XP professional (with IIS).

Following the walkthrough provided by help "creating web page for mobile
devices" , I have created a website , but as soon as I carry out the last
step in creating the website , as the website is being loaded in the IDE ,
I
get error message "Configuring web site http//localhost/DeviceWalkthrough
to ASP .NET 2.0 failed. You may need to manually configure this site for
ASP
.NET 2.0 in order for you site to run correctly ".

Could you please tell me how can I manually configure the site ?

Thank you.


>
>
>

Manually Configure site for ASP .NET 2

Hi

I am using Visual Studio 2005 on windows XP professional (with IIS).

Following the walkthrough provided by help "creating web page for mobile
devices" , I have created a website , but as soon as I carry out the last
step in creating the website , as the website is being loaded in the IDE , I
get error message "Configuring web site http//localhost/DeviceWalkthrough
to ASP .NET 2.0 failed. You may need to manually configure this site for ASP
..NET 2.0 in order for you site to run correctly ".

Could you please tell me how can I manually configure the site ?

Thank you.Hi Gol,

To set a site to use ASP.NET 2.0, right click on your web
application/virtual directory and select properties. From there, under the
ASP.NET-tab, select "ASP.NET version: 2.0.50727".

If the ASP.NET tab isn't there, you need to install ASP.NET. Run
"aspnet_regiis.exe -i" from a command window. (The .exe is located in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

Good luck!

Regards,
Nils Magnus

"Gol Yass" <gol_e_yass@.yahoo.comwrote in message
news:eceb8o$9741@.news-dxb.emirates.net.ae...

Quote:

Originally Posted by

Hi
>
I am using Visual Studio 2005 on windows XP professional (with IIS).
>
Following the walkthrough provided by help "creating web page for mobile
devices" , I have created a website , but as soon as I carry out the last
step in creating the website , as the website is being loaded in the IDE ,
I
get error message "Configuring web site http//localhost/DeviceWalkthrough
to ASP .NET 2.0 failed. You may need to manually configure this site for
ASP
.NET 2.0 in order for you site to run correctly ".
>
Could you please tell me how can I manually configure the site ?
>
>
Thank you.
>
>


Thank you very much ! I ran aspnet_regiis and it solved the problem :)

"Nils Magnus" <nmee@.nmee.netwrote in message
news:OZHun%23bxGHA.1420@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Hi Gol,
>
To set a site to use ASP.NET 2.0, right click on your web
application/virtual directory and select properties. From there, under the
ASP.NET-tab, select "ASP.NET version: 2.0.50727".
>
If the ASP.NET tab isn't there, you need to install ASP.NET. Run
"aspnet_regiis.exe -i" from a command window. (The .exe is located in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).
>
Good luck!
>
Regards,
Nils Magnus
>
>
"Gol Yass" <gol_e_yass@.yahoo.comwrote in message
news:eceb8o$9741@.news-dxb.emirates.net.ae...

Quote:

Originally Posted by

>Hi
>>
>I am using Visual Studio 2005 on windows XP professional (with IIS).
>>
>Following the walkthrough provided by help "creating web page for mobile
>devices" , I have created a website , but as soon as I carry out the last
>step in creating the website , as the website is being loaded in the IDE
>, I
>get error message "Configuring web site
>http//localhost/DeviceWalkthrough
>to ASP .NET 2.0 failed. You may need to manually configure this site for
>ASP
>.NET 2.0 in order for you site to run correctly ".
>>
>Could you please tell me how can I manually configure the site ?
>>
>>
>Thank you.
>>
>>


>
>


i am not able to configure http://localhost:8090/MyWeb to ASP.NET 2

From http://www.google.co.in/search?hl=e...NET+2.0?&meta=
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
How did you try to configure it ?

Did you create a "web site" ?
( not an application, but a *web site* which is pointed to port 8090 ? )

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"srinivas rao nandikanti" <sri_nandi@.rediffmail.comwrote in message
news:cb38adf8-033c-4bf3-9a78-d365a24dda36@.developmentnow.com...

Quote:

Originally Posted by

>i am not able to configure http://localhost:8090/MyWeb to ASP.NET 2
>
From
http://www.google.co.in/search?hl=e...NET+2.0?&meta=
>
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com


Hello srinivas,

Moreover, what do u want to configurate?
Have u read this http://blogs.msdn.com/david.wang/ar...de-by-Side.aspx
?

--
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

sri am not able to configure http://localhost:8090/MyWeb to ASP.NET 2
sr>
srFrom
srhttp://www.google.co.in/search?hl=e...y+configure+web
sr+site+http://localhost/--+to+ASP.NET+2.0?&meta=
sr>
srPosted via DevelopmentNow.com Groups
srhttp://www.developmentnow.com

Manually Configure site for ASP .NET 2

i am not able to configure http://localhost:8090/MyWeb to ASP.NET 2
From http://www.google.co.in/search?hl=e...NET+2.0?&meta=
Posted via DevelopmentNow.com Groups
http://www.developmentnow.comHow did you try to configure it ?
Did you create a "web site" ?
( not an application, but a *web site* which is pointed to port 8090 ? )
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"srinivas rao nandikanti" <sri_nandi@.rediffmail.com> wrote in message
news:cb38adf8-033c-4bf3-9a78-d365a24dda36@.developmentnow.com...
>i am not able to configure http://localhost:8090/MyWeb to ASP.NET 2
> From
> http://www.google.co.in/search?hl=e...NET+2.0?&meta=
> Posted via DevelopmentNow.com Groups
> http://www.developmentnow.com
Hello srinivas,
Moreover, what do u want to configurate?
Have u read this http://blogs.msdn.com/david.wang/ar...de-by-Side.aspx
?
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
sr> i am not able to configure http://localhost:8090/MyWeb to ASP.NET 2
sr>
sr> From
sr> http://www.google.co.in/search?hl=e...y+configure+web
sr> +site+http://localhost/--+to+ASP.NET+2.0?&meta=
sr>
sr> Posted via DevelopmentNow.com Groups
sr> http://www.developmentnow.com

manually closing DB connections...required?

We're running into a problem on our new site. Once a week or so, our site
goes down with an 'out of memory error'. Rebooting the web server fixes
things. Googling the error doesn't return many results (one, actually) and
the suggested fix is to make sure you are manually closing all DB
connections. I'm doing that now, but I had thought that asp.net had fairly
robust automated cleanup, and that having to explicitely close every
connection wasn't necessarily needed (though I certainly agree that it's
good practice). Just curious as to what .net's clean-up capabilities
actually are.

-DarrelHi darrel,

It's not a matter of .Net's cleanup capabilities. It's a matter of the
nature of database connections in .Net. What I mean is that it has nothing
to do with global .Net operations, such as garbage collection. It is
specific to database connections, due to their nature. You will find the
same type of thing with .Net classes that open and close files, and use
unmanaged resources "under the hood". For example, if you open a file, you
had better close it, or it will become unusable (until the next reboot).
Why? Because that's how the file system works. It locks files when they are
opened, and unlocks them when they are closed. A database connection is
similar, in that, you can open it and it will remain open (and in memory)
until you close it. While the connection at your end may be unused when
you're finished using it, it is still connected to the database at the other
end. Closing it disconnects it, allowing it to be cleaned up.

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

"darrel" <notreal@.hotmail.com> wrote in message
news:u0p0MNisEHA.2660@.TK2MSFTNGP12.phx.gbl...
> We're running into a problem on our new site. Once a week or so, our site
> goes down with an 'out of memory error'. Rebooting the web server fixes
> things. Googling the error doesn't return many results (one, actually) and
> the suggested fix is to make sure you are manually closing all DB
> connections. I'm doing that now, but I had thought that asp.net had fairly
> robust automated cleanup, and that having to explicitely close every
> connection wasn't necessarily needed (though I certainly agree that it's
> good practice). Just curious as to what .net's clean-up capabilities
> actually are.
> -Darrel
> While the connection at your end may be unused when
> you're finished using it, it is still connected to the database at the
other
> end. Closing it disconnects it, allowing it to be cleaned up.

While we're on this topic...is there a log anywhere or any way to see the
current open DB connections?

-Darrel
> While the connection at your end may be unused when
> you're finished using it, it is still connected to the database at the
other
> end. Closing it disconnects it, allowing it to be cleaned up.

Yikes! Wow...we screwed this one up, then. ;o)

Ok, I'm halfway through closing all our connections. This is definitely the
problem (and our fault). Thanks for clarifying that for me!

-Darrel
Oh...one more question...what is the '= nothing' for, and is that something
I should have as well?

For instance, I had:

objConnect.open()

I am now adding:
objConnect.close()

but should I also add:

objConnect = nothing

-Darrel
Hi Darrel,

The following .Net SDK article should be helpful. Along with describing
Connection Pooling, it provides several performanc counters that you can use
to view Connections:

http://msdn.microsoft.com/library/d...aProvider. asp

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

"darrel" <notreal@.hotmail.com> wrote in message
news:#R9UzyisEHA.2800@.tk2msftngp13.phx.gbl...
> > While the connection at your end may be unused when
> > you're finished using it, it is still connected to the database at the
> other
> > end. Closing it disconnects it, allowing it to be cleaned up.
> While we're on this topic...is there a log anywhere or any way to see the
> current open DB connections?
> -Darrel
Hi Darrel,

No, that' s not necessary.

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

"darrel" <notreal@.hotmail.com> wrote in message
news:OdEqh1isEHA.624@.TK2MSFTNGP09.phx.gbl...
> Oh...one more question...what is the '= nothing' for, and is that
something
> I should have as well?
> For instance, I had:
> objConnect.open()
> I am now adding:
> objConnect.close()
> but should I also add:
> objConnect = nothing
> -Darrel
> Hi Darrel,
> No, that' s not necessary.

Thanks, Kevin!

-Darrel

manually closing DB connections...required?

We're running into a problem on our new site. Once a w or so, our site
goes down with an 'out of memory error'. Rebooting the web server fixes
things. Googling the error doesn't return many results (one, actually) and
the suggested fix is to make sure you are manually closing all DB
connections. I'm doing that now, but I had thought that asp.net had fairly
robust automated cleanup, and that having to explicitely close every
connection wasn't necessarily needed (though I certainly agree that it's
good practice). Just curious as to what .net's clean-up capabilities
actually are.
-DarrelHi darrel,
It's not a matter of .Net's cleanup capabilities. It's a matter of the
nature of database connections in .Net. What I mean is that it has nothing
to do with global .Net operations, such as garbage collection. It is
specific to database connections, due to their nature. You will find the
same type of thing with .Net classes that open and close files, and use
unmanaged resources "under the hood". For example, if you open a file, you
had better close it, or it will become unusable (until the next reboot).
Why? Because that's how the file system works. It locks files when they are
opened, and unlocks them when they are closed. A database connection is
similar, in that, you can open it and it will remain open (and in memory)
until you close it. While the connection at your end may be unused when
you're finished using it, it is still connected to the database at the other
end. Closing it disconnects it, allowing it to be cleaned up.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"darrel" <notreal@.hotmail.com> wrote in message
news:u0p0MNisEHA.2660@.TK2MSFTNGP12.phx.gbl...
> We're running into a problem on our new site. Once a w or so, our site
> goes down with an 'out of memory error'. Rebooting the web server fixes
> things. Googling the error doesn't return many results (one, actually) and
> the suggested fix is to make sure you are manually closing all DB
> connections. I'm doing that now, but I had thought that asp.net had fairly
> robust automated cleanup, and that having to explicitely close every
> connection wasn't necessarily needed (though I certainly agree that it's
> good practice). Just curious as to what .net's clean-up capabilities
> actually are.
> -Darrel
>
> While the connection at your end may be unused when
> you're finished using it, it is still connected to the database at the
other
> end. Closing it disconnects it, allowing it to be cleaned up.
While we're on this topic...is there a log anywhere or any way to see the
current open DB connections?
-Darrel
> While the connection at your end may be unused when
> you're finished using it, it is still connected to the database at the
other
> end. Closing it disconnects it, allowing it to be cleaned up.
Yikes! Wow...we screwed this one up, then. ;o)
Ok, I'm halfway through closing all our connections. This is definitely the
problem (and our fault). Thanks for clarifying that for me!
-Darrel
Oh...one more question...what is the '= nothing' for, and is that something
I should have as well?
For instance, I had:
objConnect.open()
I am now adding:
objConnect.close()
but should I also add:
objConnect = nothing
-Darrel
Hi Darrel,
The following .Net SDK article should be helpful. Along with describing
Connection Pooling, it provides several performanc counters that you can use
to view Connections:
http://msdn.microsoft.com/library/d...br />
vider.asp
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"darrel" <notreal@.hotmail.com> wrote in message
news:#R9UzyisEHA.2800@.tk2msftngp13.phx.gbl...
> other
> While we're on this topic...is there a log anywhere or any way to see the
> current open DB connections?
> -Darrel
>
Hi Darrel,
No, that' s not necessary.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"darrel" <notreal@.hotmail.com> wrote in message
news:OdEqh1isEHA.624@.TK2MSFTNGP09.phx.gbl...
> Oh...one more question...what is the '= nothing' for, and is that
something
> I should have as well?
> For instance, I had:
> objConnect.open()
> I am now adding:
> objConnect.close()
> but should I also add:
> objConnect = nothing
> -Darrel
>
> Hi Darrel,
> No, that' s not necessary.
Thanks, Kevin!
-Darrel

Manually Clear Session Object and State Server

We are using State Server to host our session objects.

We have several applications running under IIS that will be using the State
Server.

How can one of those applications clear its Session state? If it was in
process, we could just stop and start the web app. We can not just stop and
start the State Server service because it would wipe out state for all
applications.

Thanks,
fmHi Fm,

Thanks for your posting. As for the problem you mentioned, I think there is
no buildin means for managea certain single application's session state
since the state server is run as a windows service on the server and
haven't any particular managment interface. But you may try modifying the
asp.net application's web.config to change the sessionstate mode to see
wheher this can make the stateserver session invalidated. For example,
change the Session Mode to InProc and run the applicaiton, then change it
back to StateServer Mode.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,

I have tried tried that in the past and I just reconfirmed it that switching
the session from InProc and back to StateServer restores the values sitting
in StateServer.

A hack I tried is setting the Timeout to 1 minute. But the session has to be
idle for the original 20 minutes before this new timeout takes affect.

Quite frustrating. Seems like an even bigger hack will be required like
having an administrator drop an include file on the server that each request
will check to see if it should call Session.RemoveAll or something.

Hopefully ASP.NET and IIS6 will be more robust then the current ASP IIS5
solution for the development team that requested this requirement so they
won't need it.

Thanks,
fm

"Steven Cheng[MSFT]" wrote:

> Hi Fm,
> Thanks for your posting. As for the problem you mentioned, I think there is
> no buildin means for managea certain single application's session state
> since the state server is run as a windows service on the server and
> haven't any particular managment interface. But you may try modifying the
> asp.net application's web.config to change the sessionstate mode to see
> wheher this can make the stateserver session invalidated. For example,
> change the Session Mode to InProc and run the applicaiton, then change it
> back to StateServer Mode.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi Steven,

Another that came to me, can more then one instance of State Server run on a
server?

Thanks,
Fm

"Steven Cheng[MSFT]" wrote:

> Hi Fm,
> Thanks for your posting. As for the problem you mentioned, I think there is
> no buildin means for managea certain single application's session state
> since the state server is run as a windows service on the server and
> haven't any particular managment interface. But you may try modifying the
> asp.net application's web.config to change the sessionstate mode to see
> wheher this can make the stateserver session invalidated. For example,
> change the Session Mode to InProc and run the applicaiton, then change it
> back to StateServer Mode.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi Fm,

AS for instance of StateServer, I think only one is existing on a
StateServer machine because the asp.net statserver is run as a windows
service, you can find it in the server's service list. Thanks.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Manually create aspnet_user

I am trying to create a user in the aspnet_user table but if keeps
failing because of the unique variables. My hoster doesn't allow me to
add users to this table other than through a t query. any help will be
appreciated.
I have looked everywhere and just keep getting more .
Yes, I am a novice. Please, a simple query would be appreciated.This article has information and code, sample pages included in the download
to do what you want:
http://www.eggheadcafe.com/articles/20060529.asp
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"happypwc@.cxoxmxcxaxsxtx.net" wrote:

> I am trying to create a user in the aspnet_user table but if keeps
> failing because of the unique variables. My hoster doesn't allow me to
> add users to this table other than through a t query. any help will be
> appreciated.
> I have looked everywhere and just keep getting more .
> Yes, I am a novice. Please, a simple query would be appreciated.
>

Manually create aspnet_user

I am trying to create a user in the aspnet_user table but if keeps
failing because of the unique variables. My hoster doesn't allow me to
add users to this table other than through a t query. any help will be
appreciated.

I have looked everywhere and just keep getting more confused.

Yes, I am a novice. Please, a simple query would be appreciated.This article has information and code, sample pages included in the download
to do what you want:

http://www.eggheadcafe.com/articles/20060529.asp

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

"happypwc@.cxoxmxcxaxsxtx.net" wrote:

> I am trying to create a user in the aspnet_user table but if keeps
> failing because of the unique variables. My hoster doesn't allow me to
> add users to this table other than through a t query. any help will be
> appreciated.
> I have looked everywhere and just keep getting more confused.
> Yes, I am a novice. Please, a simple query would be appreciated.
>

Manually created DataTable to Export in Excel Format

I manually created a Datatable and now I want to export it to my
clients in Excel format. Is there an easy way of doing this?Yes, this article explains several ways to export data to Excel:
http://www.aspnetpro.com/Newsletter...o_l.asp

I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Peter" <peter@.mclinn.com> wrote in message
news:dcde2a5a.0411091334.15c67491@.posting.google.com...
>I manually created a Datatable and now I want to export it to my
> clients in Excel format. Is there an easy way of doing this?

Manually created DataTable to Export in Excel Format

I manually created a Datatable and now I want to export it to my
clients in Excel format. Is there an easy way of doing this?Yes, this article explains several ways to export data to Excel:
http://www.aspnetpro.com/Newsletter...p200309so_l.asp

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

"Peter" <peter@.mclinn.com> wrote in message
news:dcde2a5a.0411091334.15c67491@.posting.google.c om...
>I manually created a Datatable and now I want to export it to my
> clients in Excel format. Is there an easy way of doing this?

Manually create HTML in User Control

In a few instances, I need to generate HTML manually in my user controls. What I normally do is create this HTML manually in the code behind (it is very complex) using a string builder, and then just set the text value of a literal control to the resulting string of HTML. I was wondering if there is any benefit, or if it is better practice to just override the render method in the code behind and write my HTML using the HTMLTextWriter object. Thoughts?

bounce

i thinkkk

i have heard your name somewhere before


Have you considered creating a Web User Control instead? You can write the HTML once (and include nested ASP.NET controls) and use it wherever you like.


I am using a user control. The question was regarding the best practice for manually rendering HTML in a user control, without the use of an existing templated server control.

I would think that using the HtmlTextWriter in your control's Render() method would be better than adding a literal control.

By using a literal control nested in your control, the literal control's Render() method will have to be called in addition to your control's Render() method which reduces your codes overall efficiency.

Manually creating httpwebrequest post from submitted form

I need to take the submitted form fields and manually create an httpwebrequest post (not get) to send to a non asp web service and I have been looking for ages not to try and find out how to do it without sucess. If anyone knows the right way of going about it, I'd be really grateful to see the link! the confusing part for me is that the request contains multiple parameters of different sorts...

For example, I will be using a fileupload control to pick an image to be sent, have a textbox and I'll also need to establish the type of the file uploaded and determine its length, so when I come to do the post, I will be sending the picture name (extrapolated from uploaded file), Description (from text box), a file size (extrapolated from uploaded file) and the actual file itself (usually jpg, but could be gif or png).

I must be totally daft, but I can't see how to set multiple parameters on the post request...

Use the HTTPWebRequest object to send POSTS programmatically with your code. I believe you can just create a string of value pairs like:

Dim strPost as string = "parameter1=value¶meter2=value¶meter3=value"

Then post that string to the app using the HTTPWebRequest.

If you've never done this before, you'll want to research the HTTPWebRequest object. Its a bit of a beast to get working.


Thanks, but "Dim strPost as string = parameter1=value¶meter2=value¶meter3=value"

is "get" stuff for querystring, that I don't want to do! I can't post a 800kb image in the querystring!


Hi carled,

The examples in the following Url use POST method with HTTPwebRequest. It reads data using Console.ReadLine() method, you can replace it to make it read stream from a file.

http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.method.aspx

Manually creating HTML... ASP.NET

Hi everyone, I have what is usually a familar problem but unsure about
how to solve it in ASP.NET.
I have an array of objects containing information, I would like to
create a table of these objects in my HTML page.
So in PHP, typically I would iterate through the objects generating the
html and storing it in a variable, finally i would output the variable
to the screen, wallah I have a dynamic table of data.
What is the process todo this in ASP.NET, it is difficult to convey
certain procedural steps in a fully OO environment.
Thanks for any help/advice.
Kind Regards
TazTaz,
Put a literal control on your page where you want the table to appear.
Use a stringbuilder object to create your html table.
Then output the stringbuilder (Stringbuilder.ToString) as the text of the
literal.
Of course there are other ways to do this, but that's how to mimic what you
describe exactly.
An easier way however may be to hookup your objects directly to a GridView.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
<ukbrainstorms@.gmail.com> wrote in message
news:1139500664.827360.192860@.g44g2000cwa.googlegroups.com...
> Hi everyone, I have what is usually a familar problem but unsure about
> how to solve it in ASP.NET.
> I have an array of objects containing information, I would like to
> create a table of these objects in my HTML page.
> So in PHP, typically I would iterate through the objects generating the
> html and storing it in a variable, finally i would output the variable
> to the screen, wallah I have a dynamic table of data.
> What is the process todo this in ASP.NET, it is difficult to convey
> certain procedural steps in a fully OO environment.
> Thanks for any help/advice.
> Kind Regards
> Taz
>
> Of course there are other ways to do this, but that's how to mimic what
> you describe exactly.
> An easier way however may be to hookup your objects directly to a
> GridView.
> --
> Sincerely,
Hi many thanks for your reply!
I have discovered I can use something called a HttpTable control which i
will investigate. Your suggestion will definately come in useful!
However hooking up my objects to a GridView sounds interesting, i wasnt
aware this was possible, please could u provide a little more information?
With kind regards,
Taz
Use a Repeater, and bind it to the array. See:
http://msdn.microsoft.com/library/d...rvercontrol.asp
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
We got a sick zebra a hat,
you ultimate tuna.
<ukbrainstorms@.gmail.com> wrote in message
news:1139500664.827360.192860@.g44g2000cwa.googlegroups.com...
> Hi everyone, I have what is usually a familar problem but unsure about
> how to solve it in ASP.NET.
> I have an array of objects containing information, I would like to
> create a table of these objects in my HTML page.
> So in PHP, typically I would iterate through the objects generating the
> html and storing it in a variable, finally i would output the variable
> to the screen, wallah I have a dynamic table of data.
> What is the process todo this in ASP.NET, it is difficult to convey
> certain procedural steps in a fully OO environment.
> Thanks for any help/advice.
> Kind Regards
> Taz
>
Taz,
The new asp.net 2.0 GridView object can take a list of objects (use generics
to create the list) as it's datasource. This is done via a new
"ObjectDataSource" control.
There's a great article in the January 2006 Visual Studio Magazine on doing
so. It uses the new generics objects and is really slick. Pick up a copy if
you can.
And microsoft has another how-to here, but I don't think it's using generics
(I only took a brief glance though):
http://msdn2.microsoft.com/en-us/li...c
e.aspx
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Tarun Mistry" <ukbrainstorms@.gmail.com> wrote in message
news:u3hXnxZLGHA.2904@.TK2MSFTNGP10.phx.gbl...
> Hi many thanks for your reply!
> I have discovered I can use something called a HttpTable control which i
> will investigate. Your suggestion will definately come in useful!
> However hooking up my objects to a GridView sounds interesting, i wasnt
> aware this was possible, please could u provide a little more information?
> With kind regards,
> Taz
>

Manually creating HTML... ASP.NET

Hi everyone, I have what is usually a familar problem but unsure about
how to solve it in ASP.NET.

I have an array of objects containing information, I would like to
create a table of these objects in my HTML page.

So in PHP, typically I would iterate through the objects generating the
html and storing it in a variable, finally i would output the variable
to the screen, wallah I have a dynamic table of data.

What is the process todo this in ASP.NET, it is difficult to convey
certain procedural steps in a fully OO environment.

Thanks for any help/advice.

Kind Regards
TazTaz,

Put a literal control on your page where you want the table to appear.

Use a stringbuilder object to create your html table.

Then output the stringbuilder (Stringbuilder.ToString) as the text of the
literal.

Of course there are other ways to do this, but that's how to mimic what you
describe exactly.

An easier way however may be to hookup your objects directly to a GridView.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
<ukbrainstorms@.gmail.com> wrote in message
news:1139500664.827360.192860@.g44g2000cwa.googlegr oups.com...
> Hi everyone, I have what is usually a familar problem but unsure about
> how to solve it in ASP.NET.
> I have an array of objects containing information, I would like to
> create a table of these objects in my HTML page.
> So in PHP, typically I would iterate through the objects generating the
> html and storing it in a variable, finally i would output the variable
> to the screen, wallah I have a dynamic table of data.
> What is the process todo this in ASP.NET, it is difficult to convey
> certain procedural steps in a fully OO environment.
> Thanks for any help/advice.
> Kind Regards
> Taz
> Of course there are other ways to do this, but that's how to mimic what
> you describe exactly.
> An easier way however may be to hookup your objects directly to a
> GridView.
> --
> Sincerely,

Hi many thanks for your reply!

I have discovered I can use something called a HttpTable control which i
will investigate. Your suggestion will definately come in useful!

However hooking up my objects to a GridView sounds interesting, i wasnt
aware this was possible, please could u provide a little more information?

With kind regards,
Taz
Use a Repeater, and bind it to the array. See:
http://msdn.microsoft.com/library/d...rvercontrol.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.

<ukbrainstorms@.gmail.com> wrote in message
news:1139500664.827360.192860@.g44g2000cwa.googlegr oups.com...
> Hi everyone, I have what is usually a familar problem but unsure about
> how to solve it in ASP.NET.
> I have an array of objects containing information, I would like to
> create a table of these objects in my HTML page.
> So in PHP, typically I would iterate through the objects generating the
> html and storing it in a variable, finally i would output the variable
> to the screen, wallah I have a dynamic table of data.
> What is the process todo this in ASP.NET, it is difficult to convey
> certain procedural steps in a fully OO environment.
> Thanks for any help/advice.
> Kind Regards
> Taz
Taz,

The new asp.net 2.0 GridView object can take a list of objects (use generics
to create the list) as it's datasource. This is done via a new
"ObjectDataSource" control.

There's a great article in the January 2006 Visual Studio Magazine on doing
so. It uses the new generics objects and is really slick. Pick up a copy if
you can.

And microsoft has another how-to here, but I don't think it's using generics
(I only took a brief glance though):

http://msdn2.microsoft.com/en-us/li...datasource.aspx

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Tarun Mistry" <ukbrainstorms@.gmail.com> wrote in message
news:u3hXnxZLGHA.2904@.TK2MSFTNGP10.phx.gbl...
>> Of course there are other ways to do this, but that's how to mimic what
>> you describe exactly.
>>
>> An easier way however may be to hookup your objects directly to a
>> GridView.
>>
>> --
>> Sincerely,
> Hi many thanks for your reply!
> I have discovered I can use something called a HttpTable control which i
> will investigate. Your suggestion will definately come in useful!
> However hooking up my objects to a GridView sounds interesting, i wasnt
> aware this was possible, please could u provide a little more information?
> With kind regards,
> Taz

manually determine secure pages?

You can declare 'secured' pages in Web.Config, pages that is only accessible for privileged uses. A sample of how the code in Web.Config should be, is showed in the following code:

<location path="manage.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location
As seen in the code above, the file 'manage.aspx' is only accessible for some users. However, is it possible to determine which pages are secure, via the ASP.NET application itself? I would like to build a tool, which can also determine pages that should only be accessible for privileged users... The solution that is most likely is to edit the 'Web.Config' file via the ASP.NET application. How can I do this? If it is not possible to change this file, is there another solution to handle this problem ?

I hope someone can help. Thanks!Instead of


<deny users="?" />

You can


<allow users="Lisa,Liza,Lize" />
<deny users="*" />

This will explicitly allow Lisa, Liza and Lize to access this file. All other users will be denied access, even if they are authenticated.

If access if linked to specific User Roles, you need to consider Role Based Authentication. This is not addressed in web.config, you have to develop code to handle this. There is heaps of info on Google and MSDN about this.

manually creating unique IDs

I have a table that stores the content for a web site I'm making. Each one
has a unique ID so I can grab it via the querystring.
Since it's being done via a query string, I didn't want to use default
GUIDs, since they're just really verbose.
So, I'm just making my own. What's the best way to check for uniqueness on
insert? My thinking was that I'd query the ID field, set it to an array, and
then loop through all of the variables. ie:
count = 1
while any variable in array = count then
count = count+1
end while
new item's ID = count
--
That would work, but could get extremely intensive if it were a large db.
So then I thought perhaps I'd just grab all IDs, and then sort the array,
grabbing the highest one and just add one to it. That would work too.
Are there other methods I should consider? Is there a way (via SQL?) to
automatically enter in a unique ID without needing the huge GUID?
-DarrelWhy re-invent the wheel?
Have you considered using an IDENTITY property in your table definition?
(SQL Server calls it IDENTITY, I think in Access it's "AutoIncrement").
--GH
"Darrel" <notreal@.nospam.com> wrote in message
news:uPLUVmivEHA.1260@.TK2MSFTNGP12.phx.gbl...
> I have a table that stores the content for a web site I'm making. Each one
> has a unique ID so I can grab it via the querystring.
> Since it's being done via a query string, I didn't want to use default
> GUIDs, since they're just really verbose.
> So, I'm just making my own. What's the best way to check for uniqueness on
> insert? My thinking was that I'd query the ID field, set it to an array,
and
> then loop through all of the variables. ie:
> --
> count = 1
> while any variable in array = count then
> count = count+1
> end while
> new item's ID = count
> --
> That would work, but could get extremely intensive if it were a large db.
> So then I thought perhaps I'd just grab all IDs, and then sort the array,
> grabbing the highest one and just add one to it. That would work too.
> Are there other methods I should consider? Is there a way (via SQL?) to
> automatically enter in a unique ID without needing the huge GUID?
> -Darrel
>
> Have you considered using an IDENTITY property in your table definition?
> (SQL Server calls it IDENTITY, I think in Access it's "AutoIncrement").
That's exactly the solution. Thanks! (Still new enough to SQL that I didn't
know about this one!)
-Darrel
<<Still new enough to SQL that I didn't know about this one!>>
Well, welcome to the party!
If you are new to the game I'll forewarn you that many database design
experts promote the idea that one should never or practically never use an
IDENTITY property as a primary key to a table. These experts call it a
"surrogate key" and will tell you to always use a "natural key" instead. If
you post questions about primary keys in the SQL Server news group you'll
get pounded if you talk about IDENTITY (mostly by Joe Celko). What you
should be aware of is that there are most definitely times to use an
IDENTITY or even a GUID column for a primary key. What's important is to
know when to use which - and if you do want surrogate keys - how best to
implement them in your db design.
Here is some excellent reading arguing FOR the use of surrogate keys
(IDENTITY and/or GUID):
http://www.dbpd.com/vault/9805xtra.htm
http://www.sqlteam.com/forums/topic...136&whichpage=1
This second link is to a lengthy discussion that is highly entertaining and
enlightening. This discussion started in February 2001 and the most recent
post was in July 2004. It might take an hour or so to get through it, but it
definitely contains all points of view on the whole "surrogate vs natural
key" issue. The first couple of dozen posts are of the normal "pissing
contest" variety - but a few pages into it this guy goes off on making the
case FOR surrogate keys. He has a bunch of interesting numbers and
compelling rationalle. Enjoy!
-GH

manually creating unique IDs

I have a table that stores the content for a web site I'm making. Each one
has a unique ID so I can grab it via the querystring.

Since it's being done via a query string, I didn't want to use default
GUIDs, since they're just really verbose.

So, I'm just making my own. What's the best way to check for uniqueness on
insert? My thinking was that I'd query the ID field, set it to an array, and
then loop through all of the variables. ie:

---------
count = 1

while any variable in array = count then
count = count+1
end while

new item's ID = count
----------

That would work, but could get extremely intensive if it were a large db.

So then I thought perhaps I'd just grab all IDs, and then sort the array,
grabbing the highest one and just add one to it. That would work too.

Are there other methods I should consider? Is there a way (via SQL?) to
automatically enter in a unique ID without needing the huge GUID?

-DarrelWhy re-invent the wheel?

Have you considered using an IDENTITY property in your table definition?
(SQL Server calls it IDENTITY, I think in Access it's "AutoIncrement").

--GH

"Darrel" <notreal@.nospam.com> wrote in message
news:uPLUVmivEHA.1260@.TK2MSFTNGP12.phx.gbl...
> I have a table that stores the content for a web site I'm making. Each one
> has a unique ID so I can grab it via the querystring.
> Since it's being done via a query string, I didn't want to use default
> GUIDs, since they're just really verbose.
> So, I'm just making my own. What's the best way to check for uniqueness on
> insert? My thinking was that I'd query the ID field, set it to an array,
and
> then loop through all of the variables. ie:
> ---------
> count = 1
> while any variable in array = count then
> count = count+1
> end while
> new item's ID = count
> ----------
> That would work, but could get extremely intensive if it were a large db.
> So then I thought perhaps I'd just grab all IDs, and then sort the array,
> grabbing the highest one and just add one to it. That would work too.
> Are there other methods I should consider? Is there a way (via SQL?) to
> automatically enter in a unique ID without needing the huge GUID?
> -Darrel
> Have you considered using an IDENTITY property in your table definition?
> (SQL Server calls it IDENTITY, I think in Access it's "AutoIncrement").

That's exactly the solution. Thanks! (Still new enough to SQL that I didn't
know about this one!)

-Darrel
<<Still new enough to SQL that I didn't know about this one!>
Well, welcome to the party!

If you are new to the game I'll forewarn you that many database design
experts promote the idea that one should never or practically never use an
IDENTITY property as a primary key to a table. These experts call it a
"surrogate key" and will tell you to always use a "natural key" instead. If
you post questions about primary keys in the SQL Server news group you'll
get pounded if you talk about IDENTITY (mostly by Joe Celko). What you
should be aware of is that there are most definitely times to use an
IDENTITY or even a GUID column for a primary key. What's important is to
know when to use which - and if you do want surrogate keys - how best to
implement them in your db design.

Here is some excellent reading arguing FOR the use of surrogate keys
(IDENTITY and/or GUID):

http://www.dbpd.com/vault/9805xtra.htm

http://www.sqlteam.com/forums/topic...136&whichpage=1
This second link is to a lengthy discussion that is highly entertaining and
enlightening. This discussion started in February 2001 and the most recent
post was in July 2004. It might take an hour or so to get through it, but it
definitely contains all points of view on the whole "surrogate vs natural
key" issue. The first couple of dozen posts are of the normal "pissing
contest" variety - but a few pages into it this guy goes off on making the
case FOR surrogate keys. He has a bunch of interesting numbers and
compelling rationalle. Enjoy!

-GH

MANUALLY Embedding an Image resource...

This is driving me nuts..

All I want to do is embed a logo in BMP format as a resource in my assembly. I DO NOT want to do this via code. It's not obvious to me how I can select a BMP file or paste in an image on the clipboard as a resource.

I am not looking for how to include a BMP file into the project. I want the image as a resource. There are many examples showing how to do this by code but how do I do it manually using Visual Studio's IDE.

Either embed a BMP with image/bmp mime or a JPG with an image/jpg mime

Thanks in advance.Nobody knows how to do this? Is this a glaring omission in Visual Studio functionality?

Manually get the text that a certain control posted when in IsPostBack mode...

I have a page with EnableViewState="false".
That page contains a DropDownList with dynamic items and a submit Button.

I need to get the SelectedIndex of the DropDownList on postback however all
I ever get is -1. This makes sense since on postback, the DropDownList is
now empty (ViewState data is responsible for maintaining the items).

Now the only way I can think of to get the SelectedIndex is to somehow get
the text that the DropDownList posted to the server and perform an IndexOf()
or FindByText().

My question is how do I manually get the text that a certain control posted
when in IsPostBack mode?
Is there a Collection somewhere of posted data?
Do controls expose raw posted data somewhere?

Cheers
Nathan> My question is how do I manually get the text that a certain control
> posted when in IsPostBack mode?
> Is there a Collection somewhere of posted data?
> Do controls expose raw posted data somewhere?

My solution was to subclass the DropDownList control and use the
LoadPostData method to save the postback data to a property. Here is the
code for anybody who is interested:

public class CustomDDL : DropDownList,IPostBackDataHandler
{
private string postedText;
private string text;

public string PostedText {
get {
return postedText;
}
}
public string Text {
set {
text = value;
}
}

public virtual bool LoadPostData(
string postDataKey,NameValueCollection values) {
postedText = values[postDataKey];
return false;
}
protected override void OnDataBinding(EventArgs e) {
base.OnDataBinding(e);
SelectedIndex = Items.IndexOf(Items.FindByText(text));
}
}

Manually install DLL into GAC

Is there anyone to install a DLL into the GAC? I do not have access to
the server. I only can copy files to it.
Also could I just put the DLL in the bin directory to make it work?
Will the application look there?
Thanks> Also could I just put the DLL in the bin directory to make it work?
> Will the application look there?
Yes
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/
"BillGatesFan" <klj_mcsd@.hotmail.com> wrote in message
news:1104267069.480261.68380@.z14g2000cwz.googlegroups.com...
> Is there anyone to install a DLL into the GAC? I do not have access to
> the server. I only can copy files to it.
> Also could I just put the DLL in the bin directory to make it work?
> Will the application look there?
> Thanks
>
Thanks

Manually install DLL into GAC

Is there anyone to install a DLL into the GAC? I do not have access to
the server. I only can copy files to it.

Also could I just put the DLL in the bin directory to make it work?
Will the application look there?

Thanks> Also could I just put the DLL in the bin directory to make it work?
> Will the application look there?
Yes

--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/

"BillGatesFan" <klj_mcsd@.hotmail.com> wrote in message
news:1104267069.480261.68380@.z14g2000cwz.googlegro ups.com...
> Is there anyone to install a DLL into the GAC? I do not have access to
> the server. I only can copy files to it.
> Also could I just put the DLL in the bin directory to make it work?
> Will the application look there?
> Thanks
Thanks

Manually input a value into a drop downlist box

Hi,

I have the follwoing requirment:

I have got a drop down list box populated with names of towns from my database. I want to be able to allow users to manually type in another town name if it does not exist in the list.

If a new town is added, it needs to be added to the database table so that next time the page loads, the new town is in the list.

Does any one know if this is possible using a dropdownlist?

ThanksThis is not possible with the standard DropDownList Controls in Asp.Net. You would need a third party solution, or develop your own. Here is one which is very good:

DbCombo
Another good one which is much easier to use (my biased opinion, I know)...

EasyListBox

Another example

You would take the returned value and insert it into the DB, then databind the list again (the selection does not depend on ViewState)... or alternatively, you could insert the value into the database and then use the AddItem method to add it to the list so you wouldn't have to databind again.

Another decent option for this is Andy Smith'sComboBox control.

Manually loging out user

Hi everyone,

I have a menu time called "Logout" and I was wondering how to programmatically log out the current user.

Thanks.

Hi,

you can abandon the session at menu item click and redirect the page to login page.

Session.Abandon();

Response.redirect("login.aspx");


You can link to a page in Menu item "Sign Out" and write all the processing regarding logout in this page.

Also write same logic in "Session_End" event so if user does not click on the logout and close the browser then also logout logic fires,


Hi Thanks to both of your responses, but I am a newbie in web development and if you could tell me how to capture the Session_end event it will be very helpful.

Thanks


Assuming you're using ASP.Net Membership with Forms Authentication, you can also use FormsAuthentication.SignOut() to logout the current user.

Abandoning the session works, but you might be storing other session data not relating to the currently logged-in user which you would want to keep.


Add global.asax in you application through visual studio Add new item it will automatically have

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ebent for you.


Thanks to all of you for your help. All solutions worked.

manually posting to a specific FORM

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return true> that is used to submit the form.
<form name="form1" action=http://abc.com METHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">AmilOn Jan 30, 8:40 am, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> There is a site that has multiple FORM elements. How do I programatically
> POST to a specific form? The individual FORM elements have a <input
> name=xxx type=image return true> that is used to submit the form.
> <form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
> type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56
"
> HEIGHT="18">Amil
grrhhhcfvncv
On Jan 30, 4:40 am, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> There is a site that has multiple FORM elements. How do I programatically
> POST to a specific form? The individual FORM elements have a <input
> name=xxx type=image return true> that is used to submit the form.
> <form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
> type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56
"
> HEIGHT="18">Amil
You can use HttpWebRequest class.
Sample code on VB:
Dim web_request As HttpWebRequest = Nothing
web_request = WebRequest.Create("http://form_address")
web_request.Method = "POST"
web_request.ContentType = "application/x-www-form-urlencoded"
Dim requestData As Byte() =
Encoding.GetEncoding(1252).GetBytes("test")
web_request.ContentLength = requestData.Length
Dim response_str As String
Dim requestStream As Stream
requestStream = web_request.GetRequestStream()
requestStream.Write(requestData, 0, requestData.Length)
requestStream.Close()
You cannot "POST to a specific form". A form makes a POST, and it is either
to the same page or another page. What you can do is pass an identifier fiel
d
(hidden field, for example) that tells you "which" of your FORM Tags made th
e
post.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Amil Hanish" wrote:

> There is a site that has multiple FORM elements. How do I programatically
> POST to a specific form? The individual FORM elements have a <input
> name=xxx type=image return true> that is used to submit the form.
> <form name="form1" action=http://abc.com METHOD="POST"><input name="submit
"
> type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56
"
> HEIGHT="18">Amil
>
>
I don't think you understand. There is an EXISTING site (not .NET) that has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my url
to the "action" of the specific form and trying to add all the content by 1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.
Amil
"Amil Hanish" <amilhanish@.hotmail.com> wrote in message
news:uo7xiBCRHHA.1212@.TK2MSFTNGP03.phx.gbl...
> There is a site that has multiple FORM elements. How do I programatically
> POST to a specific form? The individual FORM elements have a <input
> name=xxx type=image return true> that is used to submit the form.
> <form name="form1" action=http://abc.com METHOD="POST"><input
> name="submit" type="image" onclick="return
> checkinput();"src="/img/submit.gif" WIDTH="56" HEIGHT="18">Amil
>

On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> I don't think you understand. There is an EXISTING site (not .NET) that ha
s
> three FORM elements. I'm writing a .NET program (Windows Service) that
> needs to POST to a specific FORM of the EXISTING site. I'm setting my url
> to the "action" of the specific form and trying to add all the content by
1)
> setting the ContentLength and 2) writing the content to the request
> stream...but it doesn't seem to be working.
>
Amil, give us the code of the form.
The site is the UPS site...the tracking page...so you can view full source
there. I'm just trying to automate where I insert a tracking # and agree to
the terms. Here is a very brief snippet of the form (although there are
other forms in the full source).
When I do the POST using my httpwebrequest object, all is fine, but I just
get the same page back...no errors or anything. I'm posting to the same url
as the "action" tag below. Thanks.
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title></head>
<body>
...
<form name="trkinput" action="http://wwwapps.ups.com/WebTracking/track"
METHOD="POST">
<input type="hidden" name="loc" value="en_US" />
<input type="hidden" name="HTMLVersion" value="5.0" />
<input type="hidden" name="saveNumbers" value="null" />
<p></p>
<textarea rows="5" cols="40" name="trackNums" class="modTxtAreaTrack">
</textarea>
<p></p>
<input name="AgreeToTermsAndConditions" type="checkbox" value="yes" />
By selecting this box and the Track button, I agree to the
<a href="http://links.10026.com/?link=java script:helpModLvl('/WebTracking/terms?loc=en_US')">
Terms and Conditions
<img alt="" src="http://pics.10026.com/?src=/img/1.gif" align="bottom" border="0" height="7"
width="3"><img alt="" src="http://pics.10026.com/?src=/img/icn_popup_blue.gif" align="bottom"
border="0" height="9" width="9" /></a>.
<p></p>
<input name="track" type="image" onclick="return
wrapperCheckTerms(trkinput);"
src="/img/en/btn_track_a_v2.gif" WIDTH="56" HEIGHT="18" alt="Track" />
</form>
</body>
</html>
"Alexey Smirnov" <alexey.smirnov@.gmail.com> wrote in message
news:1170166056.186396.311380@.v33g2000cwv.googlegroups.com...
>
> On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.com> wrote:
> Amil, give us the code of the form.
>
On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.com> wrote:
> The site is the UPS site...the tracking page...so you can view full source
Amil, did you check this page?
http://www.ups.com/content/us/en/bu...ing/technology/
automated_shipping/online_tools.html
Excellent! Works like a charm! I've only tried the HTML tracking, but very
easy. Thanks!
Amil
"Alexey Smirnov" <alexey.smirnov@.gmail.com> wrote in message
news:1170197610.194812.201480@.s48g2000cws.googlegroups.com...
> On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.com> wrote:
> Amil, did you check this page?
> http://www.ups.com/content/us/en/bu...ing/technology/
> automated_shipping/online_tools.html
>

manually posting to a specific FORM

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.

<form name="form1" action=http://abc.com METHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">AmilOn Jan 30, 8:40 am, "Amil Hanish" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.
>
<form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil


grrhhhcfvncv
On Jan 30, 4:40 am, "Amil Hanish" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.
>
<form name="form1" action=http://abc.comMETHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil


You can use HttpWebRequest class.

Sample code on VB:

Dim web_request As HttpWebRequest = Nothing
web_request = WebRequest.Create("http://form_address")

web_request.Method = "POST"
web_request.ContentType = "application/x-www-form-urlencoded"

Dim requestData As Byte() =
Encoding.GetEncoding(1252).GetBytes("test")
web_request.ContentLength = requestData.Length

Dim response_str As String
Dim requestStream As Stream

requestStream = web_request.GetRequestStream()
requestStream.Write(requestData, 0, requestData.Length)
requestStream.Close()
You cannot "POST to a specific form". A form makes a POST, and it is either
to the same page or another page. What you can do is pass an identifier field
(hidden field, for example) that tells you "which" of your FORM Tags made the
post.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Amil Hanish" wrote:

Quote:

Originally Posted by

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.
>
<form name="form1" action=http://abc.com METHOD="POST"><input name="submit"
type="image" onclick="return checkinput();"src="/img/submit.gif" WIDTH="56"
HEIGHT="18">Amil
>
>
>


I don't think you understand. There is an EXISTING site (not .NET) that has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my url
to the "action" of the specific form and trying to add all the content by 1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.

Amil

"Amil Hanish" <amilhanish@.hotmail.comwrote in message
news:uo7xiBCRHHA.1212@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

There is a site that has multiple FORM elements. How do I programatically
POST to a specific form? The individual FORM elements have a <input
name=xxx type=image return truethat is used to submit the form.
>
<form name="form1" action=http://abc.com METHOD="POST"><input
name="submit" type="image" onclick="return
checkinput();"src="/img/submit.gif" WIDTH="56" HEIGHT="18">Amil
>



On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

I don't think you understand. There is an EXISTING site (not .NET) that has
three FORM elements. I'm writing a .NET program (Windows Service) that
needs to POST to a specific FORM of the EXISTING site. I'm setting my url
to the "action" of the specific form and trying to add all the content by 1)
setting the ContentLength and 2) writing the content to the request
stream...but it doesn't seem to be working.
>


Amil, give us the code of the form.
The site is the UPS site...the tracking page...so you can view full source
there. I'm just trying to automate where I insert a tracking # and agree to
the terms. Here is a very brief snippet of the form (although there are
other forms in the full source).

When I do the POST using my httpwebrequest object, all is fine, but I just
get the same page back...no errors or anything. I'm posting to the same url
as the "action" tag below. Thanks.
<html xmlns="http://www.w3.org/1999/xhtml">

<head><title></title></head>

<body>

...

<form name="trkinput" action="http://wwwapps.ups.com/WebTracking/track"
METHOD="POST">

<input type="hidden" name="loc" value="en_US" />

<input type="hidden" name="HTMLVersion" value="5.0" />

<input type="hidden" name="saveNumbers" value="null" />

<p></p>

<textarea rows="5" cols="40" name="trackNums" class="modTxtAreaTrack">

</textarea>

<p></p>

<input name="AgreeToTermsAndConditions" type="checkbox" value="yes" />

By selecting this box and the Track button, I agree to the

<a href="http://links.10026.com/?link=javascript:helpModLvl('/WebTracking/terms?loc=en_US')">

Terms and Conditions

<img alt="" src="http://pics.10026.com/?src=/img/1.gif" align="bottom" border="0" height="7"
width="3"><img alt="" src="http://pics.10026.com/?src=/img/icn_popup_blue.gif" align="bottom"
border="0" height="9" width="9" /></a>.

<p></p>

<input name="track" type="image" onclick="return
wrapperCheckTerms(trkinput);"

src="/img/en/btn_track_a_v2.gif" WIDTH="56" HEIGHT="18" alt="Track" />

</form>

</body>

</html>

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1170166056.186396.311380@.v33g2000cwv.googlegr oups.com...

Quote:

Originally Posted by

>
>
On Jan 30, 2:33 pm, "Amil Hanish" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

>I don't think you understand. There is an EXISTING site (not .NET) that
>has
>three FORM elements. I'm writing a .NET program (Windows Service) that
>needs to POST to a specific FORM of the EXISTING site. I'm setting my
>url
>to the "action" of the specific form and trying to add all the content by
>1)
>setting the ContentLength and 2) writing the content to the request
>stream...but it doesn't seem to be working.
>>


>
Amil, give us the code of the form.
>


On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

The site is the UPS site...the tracking page...so you can view full source


Amil, did you check this page?
http://www.ups.com/content/us/en/bu...ing/technology/
automated_shipping/online_tools.html
Excellent! Works like a charm! I've only tried the HTML tracking, but very
easy. Thanks!

Amil

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1170197610.194812.201480@.s48g2000cws.googlegr oups.com...

Quote:

Originally Posted by

On 30 Jan., 19:06, "Amil" <amilhan...@.hotmail.comwrote:

Quote:

Originally Posted by

>The site is the UPS site...the tracking page...so you can view full
>source


>
Amil, did you check this page?
http://www.ups.com/content/us/en/bu...ing/technology/
automated_shipping/online_tools.html
>

manually removing ALL items from dropdownlist

Hi I want to loop through and manually remove all the items from a dropdownlist, I want to leave the viewstate on the control though as it is required most of the time. Here is the code that i thought should work but as you have guessed it doesn't the error produced is:

"Collection was modified; enumeration operation may not execute."


Dim item As ListItem
For Each item In drpPrivate.Items
drpPrivate.Items.Remove(item)
Next item

Please could you tell me how to remove all the items from a dropdownlist without resorting to EnableViewState="false"


drpPrivate.Items.Clear()

Manually Reset Validation Status

Once I manually call the Validation routine via Page_ClientValidate(); which displays the validation summary great, how can I manually turn it off if I want, even if the page is currently not valid?
I tried setting the boolean for Page_ValidationActive to false but it didn't make the validation text disappear again. Do I need to call some other function after setting the boolean to false like Page_ClientDontValidate() =)
Page_ValidationActiveBoolean variableIndicates whether validation should take place. Set this variable to False to turn off validation programmatically.
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp
hello.
i think that you're talking about the summary shown by the validationsummary control, right?
if you want to hide them, then you can use the jscript array Page_ValidationSummaries to get a reference to all the valiadtion summaries that exist in a page and then you can set it's display to none. here's an example of how to hide all the summaries:
for( var i = 0; i < Page_ValidationSummaries.length; i++ )
{
Page_ValidationSummariesIdea [I].style.display = "none";
}
Thank you for writing, that worked a little too good. =) When I try to get the validators to fire again, they won't show up. I guess I'm looking for a way to "reset" the page back to the way it was on page load, but still allow the validators to work as normal on the next change to the text that would fire the validators again.
The only way I can think of is to combine your function above, with another function that gets called onchange for each field and does the same thing but the opposite value, Page_ValidationSummariesIdea [I].style.display=Page_IsValid? block : none;
Seems like a lot processing to reset the state.
The reason I'm doing this is I use drop down list onchange with ajax that refreshes the data on the page and Page_Load doesn't get called after the Initial Load of the page.
John

Manually render a aspnet form

Hello:
Is there a way that I can manually render an ASP.NET form? I have an
ASP.NET form, but I don't want to send the HTML generated by the form
to the browser. I want to create an instance of the ASP.NET form in
one of my class, and then use the HTML code generated by the form. Is
it possible?
thanks
JSLTry Server.Execute:
http://msdn.microsoft.com/library/d...op
ic.asp
http://www.webswapp.com
http://www.societopia.net
"Jinsong Liu" wrote:

> Hello:
> Is there a way that I can manually render an ASP.NET form? I have an
> ASP.NET form, but I don't want to send the HTML generated by the form
> to the browser. I want to create an instance of the ASP.NET form in
> one of my class, and then use the HTML code generated by the form. Is
> it possible?
> thanks
> JSL
>

Manually render a aspnet form

Hello:

Is there a way that I can manually render an ASP.NET form? I have an
ASP.NET form, but I don't want to send the HTML generated by the form
to the browser. I want to create an instance of the ASP.NET form in
one of my class, and then use the HTML code generated by the form. Is
it possible?

thanks

JSLTry Server.Execute
http://msdn.microsoft.com/library/d...cutetopic.a sp

--
http://www.webswapp.com
http://www.societopia.net

"Jinsong Liu" wrote:

> Hello:
> Is there a way that I can manually render an ASP.NET form? I have an
> ASP.NET form, but I don't want to send the HTML generated by the form
> to the browser. I want to create an instance of the ASP.NET form in
> one of my class, and then use the HTML code generated by the form. Is
> it possible?
> thanks
> JSL

manually Send file to client

Is there a way to code it so that you can transmit a file to a client
programatically so that you could send it a file that is not part of
your website?
Like if my site is in c:\inetpub\mySite
Is there a way I can use like FileStream and read in a file from c:\
and then somehow transmit it to the client. (Purpose being to force the
user to go thru the website to access files and stop someone from
directly putting the url of the file they want to download in the
address bar)
I'm not sure how to transmit the data to the client though. Any ideas?
Thanks very much.You can use Response.WriteFile to write any file on the server out to the
client. So if the file is outside the virtual directory, WriteFile will
write it out just fine, but the user would have no way of specifying a URL
for it, since it will be outside the virtual directory.
<wackyphill@.yahoo.com> wrote in message
news:1105564487.576317.324950@.c13g2000cwb.googlegroups.com...
> Is there a way to code it so that you can transmit a file to a client
> programatically so that you could send it a file that is not part of
> your website?
> Like if my site is in c:\inetpub\mySite
> Is there a way I can use like FileStream and read in a file from c:\
> and then somehow transmit it to the client. (Purpose being to force the
> user to go thru the website to access files and stop someone from
> directly putting the url of the file they want to download in the
> address bar)
> I'm not sure how to transmit the data to the client though. Any ideas?
> Thanks very much.
>
Yeah, that works very well for downloading.
How about this though:?
You know how if you link to a .NET app in a web page and the client
clicks on the link using IE the program is downloaded and executed on
the client's machine?
Anyway of reproducing that same "link clicked" type behavior for a .NET
app (using Response.Writefile or something else) I have outside my
website so it will run automatically instead of the user having to hit
run on the save/as dialog?
Because w/ regular links the program simply runs when its link is
clicked. I'm not sure what the header's are that get sent when a link
is clicked like that.
You might want to use a Smart Client application if you want an app to run
when they click on the link.
The user is always going to be presented with a dialog box before any file
is downloaded to their computer though. This security precaution is well
warranted.
Would you want web sites automatically downloading strange files to your
computer without your permission? I think not.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<wackyphill@.yahoo.com> wrote in message
news:1105571359.621383.59490@.f14g2000cwb.googlegroups.com...
> Yeah, that works very well for downloading.
> How about this though:?
> You know how if you link to a .NET app in a web page and the client
> clicks on the link using IE the program is downloaded and executed on
> the client's machine?
> Anyway of reproducing that same "link clicked" type behavior for a .NET
> app (using Response.Writefile or something else) I have outside my
> website so it will run automatically instead of the user having to hit
> run on the save/as dialog?
> Because w/ regular links the program simply runs when its link is
> clicked. I'm not sure what the header's are that get sent when a link
> is clicked like that.
>
I'm not sure what you mean by smart client.
And there is no confirmation when you click on a link to a .net
executable. It is downloaded cached and run w/o any user interaction at
all.
The only thing you may have to do is set the source as being trusted
depending on what the app needs to do.

manually Send file to client

Is there a way to code it so that you can transmit a file to a client
programatically so that you could send it a file that is not part of
your website?

Like if my site is in c:\inetpub\mySite

Is there a way I can use like FileStream and read in a file from c:\
and then somehow transmit it to the client. (Purpose being to force the
user to go thru the website to access files and stop someone from
directly putting the url of the file they want to download in the
address bar)

I'm not sure how to transmit the data to the client though. Any ideas?
Thanks very much.You can use Response.WriteFile to write any file on the server out to the
client. So if the file is outside the virtual directory, WriteFile will
write it out just fine, but the user would have no way of specifying a URL
for it, since it will be outside the virtual directory.

<wackyphill@.yahoo.com> wrote in message
news:1105564487.576317.324950@.c13g2000cwb.googlegr oups.com...
> Is there a way to code it so that you can transmit a file to a client
> programatically so that you could send it a file that is not part of
> your website?
> Like if my site is in c:\inetpub\mySite
> Is there a way I can use like FileStream and read in a file from c:\
> and then somehow transmit it to the client. (Purpose being to force the
> user to go thru the website to access files and stop someone from
> directly putting the url of the file they want to download in the
> address bar)
> I'm not sure how to transmit the data to the client though. Any ideas?
> Thanks very much.
Yeah, that works very well for downloading.

How about this though:?

You know how if you link to a .NET app in a web page and the client
clicks on the link using IE the program is downloaded and executed on
the client's machine?

Anyway of reproducing that same "link clicked" type behavior for a .NET
app (using Response.Writefile or something else) I have outside my
website so it will run automatically instead of the user having to hit
run on the save/as dialog?

Because w/ regular links the program simply runs when its link is
clicked. I'm not sure what the header's are that get sent when a link
is clicked like that.
You might want to use a Smart Client application if you want an app to run
when they click on the link.
The user is always going to be presented with a dialog box before any file
is downloaded to their computer though. This security precaution is well
warranted.
Would you want web sites automatically downloading strange files to your
computer without your permission? I think not.

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

<wackyphill@.yahoo.com> wrote in message
news:1105571359.621383.59490@.f14g2000cwb.googlegro ups.com...
> Yeah, that works very well for downloading.
> How about this though:?
> You know how if you link to a .NET app in a web page and the client
> clicks on the link using IE the program is downloaded and executed on
> the client's machine?
> Anyway of reproducing that same "link clicked" type behavior for a .NET
> app (using Response.Writefile or something else) I have outside my
> website so it will run automatically instead of the user having to hit
> run on the save/as dialog?
> Because w/ regular links the program simply runs when its link is
> clicked. I'm not sure what the header's are that get sent when a link
> is clicked like that.
I'm not sure what you mean by smart client.

And there is no confirmation when you click on a link to a .net
executable. It is downloaded cached and run w/o any user interaction at
all.

The only thing you may have to do is set the source as being trusted
depending on what the app needs to do.

Manually specifying columns in a datagrid

Hi, I have a dataview that 'views' some information returned by a dataset.

I can autobind a datagrid to the view so that all information is automatically populated within the datagrid.

What I wuld like to do is specify the column headers as well as their associated attribute in the dataset via code.

e.g datagrid.columns.add(....

thanks for any help/ advice

MarkusJTry something like this:


Dim dt As New DataTable
Dim ds as new DataSet
Dim dc as DataColumn()
dc = New DataColumn()
dc.ColumnName = "Index"
dc.DataType = System.Type.GetType("System.Int16")
dc.ReadOnly = True
dt.Columns.Add(dc)
ds.Tables.Add(dt)
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Hope this helps ya,
Cool thanks :)

Manually sorting a gridview, am I plain stupid?

I have a an aspx page with a gridview.
The gridview is data bound to a generic list of custom classes.
The gridview's DataSource is thus not set.
Now I want to add sorting to it.
So I create an eventhandler thus:
Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
Static Sorting As Boolean = False
If Not Sorting Then
Sorting = True
GridViewSortExpression = e.SortExpression
grdResult.Sort(GridViewSortExpression, GetSortDirection)
grdResult.DataBind()
End If
End Sub
The effect is that the gridview doesn't get rendered.
If I comment out the databind it gets rendered but not sorted.
In debug mode I can se that the grid is populated allright.
What am I doing wrong?
/kIf I recall correctly, the ObjectDataSource caches data so that when
you sort and page you don't need to rebind to data. If you call
DataBind without providing a DataSource, you will bind to null, and
you'll get no GridView.
If you want to implement custom sorting, you're better to handle the
sorting event, grab your List again and sort it yourself before calling
DataBind.
You can always cache the List if the data isn't changing in between. I
assume that the ODS stores the data in ViewState, so there shouldn't be
any penalty to doing likewise.
Can anyone clarify that for me?
kurt sune wrote:

> I have a an aspx page with a gridview.
> The gridview is data bound to a generic list of custom classes.
> The gri dview's DataSource is thus not set.
> Now I want to add sorting to it.
> So I create an eventhandler thus:
> Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
> Static Sorting As Boolean = False
> If Not Sorting Then
> Sorting = True
> GridViewSortExpression = e.SortExpression
> grdResult.Sort(GridViewSortExpression, GetSortDirection)
> grdResult.DataBind()
> End If
> End Sub
> The effect is that the gridview doesn't get rendered.
> If I comment out the databind it gets rendered but not sorted.
> In debug mode I can se that the grid is populated allright.
> What am I doing wrong?
> /k
> If you want to implement custom sorting, you're better to handle the
> sorting event, grab your List again and sort it yourself before calling
> DataBind.
Do you know if I can grab the List again from viewstate
or must I save it there myself, thus having it in there two times?
(I mean serialize my custom classes and persist them in viewstate)
I do not want to fetch the data again from the business layer, just sort the
existing grid with the same old data.
/k
Well it looks like you got your answer to the sorting question.
I think it's about time someone tackled the other question, "are you plain
stupid.?"
Found out that the gridview doesnt support sorting in itself.
So I ended up with a custom web control with a gridview and added support
for clientside sorting by means of javascript.
That also made it possible to eliminate viewstate.
/k

Manually sorting a gridview, am I plain stupid?

I have a an aspx page with a gridview.
The gridview is data bound to a generic list of custom classes.
The gridview's DataSource is thus not set.

Now I want to add sorting to it.

So I create an eventhandler thus:

Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
Static Sorting As Boolean = False
If Not Sorting Then
Sorting = True
GridViewSortExpression = e.SortExpression
grdResult.Sort(GridViewSortExpression, GetSortDirection)
grdResult.DataBind()
End If
End Sub

The effect is that the gridview doesn't get rendered.
If I comment out the databind it gets rendered but not sorted.
In debug mode I can se that the grid is populated allright.

What am I doing wrong?

/kIf I recall correctly, the ObjectDataSource caches data so that when
you sort and page you don't need to rebind to data. If you call
DataBind without providing a DataSource, you will bind to null, and
you'll get no GridView.

If you want to implement custom sorting, you're better to handle the
sorting event, grab your List again and sort it yourself before calling
DataBind.

You can always cache the List if the data isn't changing in between. I
assume that the ODS stores the data in ViewState, so there shouldn't be
any penalty to doing likewise.

Can anyone clarify that for me?

kurt sune wrote:

Quote:

Originally Posted by

I have a an aspx page with a gridview.
The gridview is data bound to a generic list of custom classes.
The gri dview's DataSource is thus not set.
>
Now I want to add sorting to it.
>
So I create an eventhandler thus:
>
Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
Static Sorting As Boolean = False
If Not Sorting Then
Sorting = True
GridViewSortExpression = e.SortExpression
grdResult.Sort(GridViewSortExpression, GetSortDirection)
grdResult.DataBind()
End If
End Sub
>
The effect is that the gridview doesn't get rendered.
If I comment out the databind it gets rendered but not sorted.
In debug mode I can se that the grid is populated allright.
>
What am I doing wrong?
>
/k


If you want to implement custom sorting, you're better to handle the

Quote:

Originally Posted by

sorting event, grab your List again and sort it yourself before calling
DataBind.


Do you know if I can grab the List again from viewstate
or must I save it there myself, thus having it in there two times?

(I mean serialize my custom classes and persist them in viewstate)

I do not want to fetch the data again from the business layer, just sort the
existing grid with the same old data.

/k
Well it looks like you got your answer to the sorting question.

I think it's about time someone tackled the other question, "are you plain
stupid.?"
Found out that the gridview doesnt support sorting in itself.
So I ended up with a custom web control with a gridview and added support
for clientside sorting by means of javascript.
That also made it possible to eliminate viewstate.

/k