Thursday, March 29, 2012
Offset from GMT
from Active Directory. I want to present current dates and times to the
users in cases where the raw date/time is in GMT. Since the GMT offset
changes depending on the time of year, the program would need to change
twice a year. If I can determine the current offset from GMT from the
system, then I wouldn't have to change the program. I know that the system
knows the offset since it records the dates in GMT. Is it an easy value to
obtain from the system? My .Net skills are quite rudimentary. Thanks for
any help or references.You can use the DataTime.ToUniversalTime() method to set any local DateTime
to GMT. Similarly, you can find the offset of local time to GMT by
subtracting the local time from the local time as GMT, using the same
method.
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"Rich Raffenetti" <raffenetti@.comcast.net> wrote in message
news:O6NzDT0YGHA.3880@.TK2MSFTNGP04.phx.gbl...
>I have an asp.net application that presents some user account information
>from Active Directory. I want to present current dates and times to the
>users in cases where the raw date/time is in GMT. Since the GMT offset
>changes depending on the time of year, the program would need to change
>twice a year. If I can determine the current offset from GMT from the
>system, then I wouldn't have to change the program. I know that the system
>knows the offset since it records the dates in GMT. Is it an easy value to
>obtain from the system? My .Net skills are quite rudimentary. Thanks for
>any help or references.
>
Offset from GMT
from Active Directory. I want to present current dates and times to the
users in cases where the raw date/time is in GMT. Since the GMT offset
changes depending on the time of year, the program would need to change
twice a year. If I can determine the current offset from GMT from the
system, then I wouldn't have to change the program. I know that the system
knows the offset since it records the dates in GMT. Is it an easy value to
obtain from the system? My .Net skills are quite rudimentary. Thanks for
any help or references.You can use the DataTime.ToUniversalTime() method to set any local DateTime
to GMT. Similarly, you can find the offset of local time to GMT by
subtracting the local time from the local time as GMT, using the same
method.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"Rich Raffenetti" <raffenetti@.comcast.net> wrote in message
news:O6NzDT0YGHA.3880@.TK2MSFTNGP04.phx.gbl...
>I have an asp.net application that presents some user account information
>from Active Directory. I want to present current dates and times to the
>users in cases where the raw date/time is in GMT. Since the GMT offset
>changes depending on the time of year, the program would need to change
>twice a year. If I can determine the current offset from GMT from the
>system, then I wouldn't have to change the program. I know that the system
>knows the offset since it records the dates in GMT. Is it an easy value to
>obtain from the system? My .Net skills are quite rudimentary. Thanks for
>any help or references.
Monday, March 26, 2012
Oirgin Page of a Redirect
Page1 and Page2 redirect to Page3. I want the content on Page3 to be regualated based on where the user has been redirected from.
How can i check on Page3 the oirgin of the user, the previous page? I could include something in the URL in Querystring form but want to leave that as a last resort.
Thanks
Try to put on Page1 a button set it's PostBackUrl to Page3 and on Page2 the same as the button on Page1. in this case, in Page3 you can use Page.PreviousPage
HC
OK , my dumb question for the day
If IsPostBack Then
'Put user code to initialize the page here
' create a sqlconnection
Dim cnn As SqlConnection = New SqlConnection("Data
Source=localhost;Initial catalog=Northwind;" & _
"Integrated Security=SSPI")
'create a sql command
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT * FROM Suppliers"
' Set up the DataAdapter and fill the dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As Suppliers = New Suppliers
da.Fill(ds, "Suppliers")
Dim suppROW As Suppliers.SuppliersRow
For Each suppROW In ds.Suppliers
Me.ddlData.Items.Add(suppROW.SupplierID & suppROW.CompanyName)
Next
i want to set the text of the drop down to companyname
and the value to the supplierID. What am i missing?
thanks
kesHi Kes,
You need to bind the dataset to the dropdown.
Replace this:
> da.Fill(ds, "Suppliers")
> Dim suppROW As Suppliers.SuppliersRow
> For Each suppROW In ds.Suppliers
> Me.ddlData.Items.Add(suppROW.SupplierID &
suppROW.CompanyName)
> Next
With this:
da.Fill(ds, "Suppliers")
ddlData.DataTextField = "CompanyName"
ddlData.DataValueField = "SupplierID"
ddlData.DataSource = dsSuppliers
ddlData.DataBind()
I'm assuming that your Suppliers object is derived from Dataset in the
example above. Good luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:AB8DDAD7-DBE8-4093-BD3D-C91677304F3F@.microsoft.com...
> i have a drop down list fill using the following code:
> If IsPostBack Then
> 'Put user code to initialize the page here
> ' create a sqlconnection
> Dim cnn As SqlConnection = New SqlConnection("Data
> Source=localhost;Initial catalog=Northwind;" & _
> "Integrated Security=SSPI")
> 'create a sql command
> Dim cmd As SqlCommand = cnn.CreateCommand
> cmd.CommandType = Data.CommandType.Text
> cmd.CommandText = "SELECT * FROM Suppliers"
> ' Set up the DataAdapter and fill the dataset
> Dim da As SqlDataAdapter = New SqlDataAdapter
> da.SelectCommand = cmd
> Dim ds As Suppliers = New Suppliers
> da.Fill(ds, "Suppliers")
> Dim suppROW As Suppliers.SuppliersRow
> For Each suppROW In ds.Suppliers
> Me.ddlData.Items.Add(suppROW.SupplierID &
suppROW.CompanyName)
> Next
> i want to set the text of the drop down to companyname
> and the value to the supplierID. What am i missing?
> thanks
> kes
and I knew that!!
I'm working through a book and i got brain lock on this
thanks
kes
"Ken Dopierala Jr." wrote:
> Hi Kes,
> You need to bind the dataset to the dropdown.
> Replace this:
>
> suppROW.CompanyName)
> With this:
> da.Fill(ds, "Suppliers")
> ddlData.DataTextField = "CompanyName"
> ddlData.DataValueField = "SupplierID"
> ddlData.DataSource = dsSuppliers
> ddlData.DataBind()
> I'm assuming that your Suppliers object is derived from Dataset in the
> example above. Good luck! Ken.
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
> "WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
> news:AB8DDAD7-DBE8-4093-BD3D-C91677304F3F@.microsoft.com...
> suppROW.CompanyName)
>
>
OK , my dumb question for the day
If IsPostBack Then
'Put user code to initialize the page here
' create a sqlconnection
Dim cnn As SqlConnection = New SqlConnection("Data
Source=localhost;Initial catalog=Northwind;" & _
"Integrated Security=SSPI")
'create a sql command
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT * FROM Suppliers"
' Set up the DataAdapter and fill the dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As Suppliers = New Suppliers
da.Fill(ds, "Suppliers")
Dim suppROW As Suppliers.SuppliersRow
For Each suppROW In ds.Suppliers
Me.ddlData.Items.Add(suppROW.SupplierID & suppROW.CompanyName)
Next
i want to set the text of the drop down to companyname
and the value to the supplierID. What am i missing?
thanks
kesHi Kes,
You need to bind the dataset to the dropdown.
Replace this:
> da.Fill(ds, "Suppliers")
> Dim suppROW As Suppliers.SuppliersRow
> For Each suppROW In ds.Suppliers
> Me.ddlData.Items.Add(suppROW.SupplierID &
suppROW.CompanyName)
> Next
With this:
da.Fill(ds, "Suppliers")
ddlData.DataTextField = "CompanyName"
ddlData.DataValueField = "SupplierID"
ddlData.DataSource = dsSuppliers
ddlData.DataBind()
I'm assuming that your Suppliers object is derived from Dataset in the
example above. Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:AB8DDAD7-DBE8-4093-BD3D-C91677304F3F@.microsoft.com...
> i have a drop down list fill using the following code:
> If IsPostBack Then
> 'Put user code to initialize the page here
> ' create a sqlconnection
> Dim cnn As SqlConnection = New SqlConnection("Data
> Source=localhost;Initial catalog=Northwind;" & _
> "Integrated Security=SSPI")
> 'create a sql command
> Dim cmd As SqlCommand = cnn.CreateCommand
> cmd.CommandType = Data.CommandType.Text
> cmd.CommandText = "SELECT * FROM Suppliers"
> ' Set up the DataAdapter and fill the dataset
> Dim da As SqlDataAdapter = New SqlDataAdapter
> da.SelectCommand = cmd
> Dim ds As Suppliers = New Suppliers
> da.Fill(ds, "Suppliers")
> Dim suppROW As Suppliers.SuppliersRow
> For Each suppROW In ds.Suppliers
> Me.ddlData.Items.Add(suppROW.SupplierID &
suppROW.CompanyName)
> Next
> i want to set the text of the drop down to companyname
> and the value to the supplierID. What am i missing?
> thanks
> kes
and I knew that!!
I'm working through a book and i got brain lock on this
thanks
kes
"Ken Dopierala Jr." wrote:
> Hi Kes,
> You need to bind the dataset to the dropdown.
> Replace this:
> > da.Fill(ds, "Suppliers")
> > Dim suppROW As Suppliers.SuppliersRow
> > For Each suppROW In ds.Suppliers
> > Me.ddlData.Items.Add(suppROW.SupplierID &
> suppROW.CompanyName)
> > Next
> With this:
> da.Fill(ds, "Suppliers")
> ddlData.DataTextField = "CompanyName"
> ddlData.DataValueField = "SupplierID"
> ddlData.DataSource = dsSuppliers
> ddlData.DataBind()
> I'm assuming that your Suppliers object is derived from Dataset in the
> example above. Good luck! Ken.
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
> "WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
> news:AB8DDAD7-DBE8-4093-BD3D-C91677304F3F@.microsoft.com...
> > i have a drop down list fill using the following code:
> > If IsPostBack Then
> > 'Put user code to initialize the page here
> > ' create a sqlconnection
> > Dim cnn As SqlConnection = New SqlConnection("Data
> > Source=localhost;Initial catalog=Northwind;" & _
> > "Integrated Security=SSPI")
> > 'create a sql command
> > Dim cmd As SqlCommand = cnn.CreateCommand
> > cmd.CommandType = Data.CommandType.Text
> > cmd.CommandText = "SELECT * FROM Suppliers"
> > ' Set up the DataAdapter and fill the dataset
> > Dim da As SqlDataAdapter = New SqlDataAdapter
> > da.SelectCommand = cmd
> > Dim ds As Suppliers = New Suppliers
> > da.Fill(ds, "Suppliers")
> > Dim suppROW As Suppliers.SuppliersRow
> > For Each suppROW In ds.Suppliers
> > Me.ddlData.Items.Add(suppROW.SupplierID &
> suppROW.CompanyName)
> > Next
> > i want to set the text of the drop down to companyname
> > and the value to the supplierID. What am i missing?
> > thanks
> > kes
>
OK, What am I missing?@!?
I'm playing with Visual Web Developer 2005 Express Edition, coming from VisualStudio 2003.net.
I have a user control in the [application root]/util/controls directory. I have another control in that directory that needs to use the first control. I have in the ascx file of the second control the following line:
<%@dotnet.itags.org. Register TagPrefix="uc2" TagName="BannerTop" src="http://pics.10026.com/?src=/Util/Controls/BannerTop.ascx" %>
When I try to use the control (<uc2:BannerTopID="BannerTop1"runat="server"/>)I get an error saying that the file located at ~Util/Controls/Util/Controls/BannerTop.ascx could not be found (NOTE the duplicated path and the ~, I think indicating that it's trying to do a relative path).
WHY? Who the heck told it to use a relative path (NOTE the "/" at the beginning of the SRC line!)
Even when I delete the embedded control and then drag it in using the Visual Web Developer 2005 express edition, it does the same thing! Very frustrating
Am I missing something?
TIA,
When I try to use the control (<uc2:BannerTopID="BannerTop1"runat="server"/>)
What exactly do you mean by this? Are you trying to reference this control in code?
I'm trying to put the control on the web page in the aspx file. Did this syntax radically change with 2.0?
Pretty standard syntax in 1.1 to put a user control on a web page (See page 63 of the Microsoft Press book "Developing Microsoft ASP.Net Server Controls and Components" by Kothari and Datye)... I use it all over my 1.1 site....
For example:
<%@.PageLanguage="vb"AutoEventWireup="false"Inherits="cwsBackOffice.index"CodeFile="index.aspx.vb" %>
<%@.RegisterSrc="/Util/Controls/cwsbackofficecontainer.ascx"TagName="cwsbackofficecontainer"TagPrefix="uc1" %>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>
index
</title>
<body>
<formid="Form1"method="post"runat="server">
<uc1:cwsbackofficecontainerid="Cwsbackofficecontainer1"runat="server">
</uc1:cwsbackofficecontainer>
</form>
</body>
One thing I notice is that when dragging a UC into a Web Form (Html View or Design View doesn't matter in VS 2005), the Tilde (~) is inserted by default. This makes sense as Physical Path detection with the advent of Master Pages and storing systems for UCs etc should not be a concern of the developer. Example below showing how the .ascx file is referenced in VS2005 (drag'n drop):
<%@.RegisterSrc="~/UserControls/UC_Newsmodule.ascx"TagName="newsmodule"TagPrefix="uc2"%>
Doesn't work for me, though (with a VS2003 converted project anyway). I drag it in, I get the "~/UserControls/whatever.ascx" line, but then the compiler complains that "/UserControls/UserControls/whatever.ascx" cannot be found... I went in and hand edited the line, removing the tilde, and that part worked.
Except now it still insists that it doesn't know what the TagName objectis.
I think the problem lies in that the new Visual Web Developer doesn't know which parts of the project are code-library-type-things and which are web pages, etc. The project this was converted from used several code-library objects (written by us, compiled as part of the project) that seem to have been just copied to the new web project with no information provided to the web project as to how to use them (as objects!).
For instance, we have an in-house membership object called Membership.member. In the VS2003 source project, it is identified as a separate VB project (code-library) that is then referenced in the web project. How do I do this in the new Visual Web Developer 2005? I can't seem to add a code-library object to the project.
cheers,
OK. Again...How to handle single quotes in SQL Strings? ASP.NET/ADO.NET
Bob's mini mart?
If I use command objects will this no longer be an issue?
I guess that would mean no simple adhoc SQL statements right?
like SELECT name from WHATEVER
would need a command object with
"SELECT @dotnet.itags.org.NAME, etc.
and then params
is this the way to solve the problem?
Thanks,
ShaneUse command objects. The single quote "problem" will go away.
Don't use ad-hoc SQL statements that are concatenated from user input. You
are leaving your application vulnerable to a SQL injection attack.
Colin
"SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> How can I handle the user entering single quotes like in
> Bob's mini mart?
> If I use command objects will this no longer be an issue?
> I guess that would mean no simple adhoc SQL statements right?
> like SELECT name from WHATEVER
> would need a command object with
> "SELECT @.NAME, etc.
> and then params
> is this the way to solve the problem?
> Thanks,
> Shane
>
>
Yes, use parameter objects.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> How can I handle the user entering single quotes like in
> Bob's mini mart?
> If I use command objects will this no longer be an issue?
> I guess that would mean no simple adhoc SQL statements right?
> like SELECT name from WHATEVER
> would need a command object with
> "SELECT @.NAME, etc.
> and then params
> is this the way to solve the problem?
> Thanks,
> Shane
>
>
OK. That is what I had thought.
So to do that in command ojbects I do something like.
dim cmd as new sqlCommand("SELECT Name,Address,City FROM tblPerson WHERE
State=@.State",conn)
is that right? And then just add @.State as a param?
I don't need to do the same for the output params right? LIke Name, Address
and City--or do I have to do them the same?
Shane
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:Og3zd2sSEHA.1168@.TK2MSFTNGP11.phx.gbl...
> Yes, use parameter objects.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
> news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
>
Basically correct.
Output parameters would need to be declared, but in your example, you
seem to be returning a recordset, not output parameters. This would
return a .NET dataset with multiple records which you could either
bind to an ASP control or use in whatever method you deem prudent :)
On Sun, 6 Jun 2004 09:49:15 -0500, "SStory"
<TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
>OK. That is what I had thought.
>So to do that in command ojbects I do something like.
>dim cmd as new sqlCommand("SELECT Name,Address,City FROM tblPerson WHERE
>State=@.State",conn)
>is that right? And then just add @.State as a param?
>I don't need to do the same for the output params right? LIke Name, Addres
s
>and City--or do I have to do them the same?
>Shane
>
>"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>news:Og3zd2sSEHA.1168@.TK2MSFTNGP11.phx.gbl...
>
Thanks Dan,
Will try to go through and fix offending code.
Shane
"Dan Brussee" <dbrussee@.nc.rr.com> wrote in message
news:7ve6c0ls13v3k00iu79pbdf20ggd73m8tp@.
4ax.com...
> Basically correct.
> Output parameters would need to be declared, but in your example, you
> seem to be returning a recordset, not output parameters. This would
> return a .NET dataset with multiple records which you could either
> bind to an ASP control or use in whatever method you deem prudent :)
>
> On Sun, 6 Jun 2004 09:49:15 -0500, "SStory"
> <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
>
Address
>
OK. Again...How to handle single quotes in SQL Strings? ASP.NET/ADO.NET
Bob's mini mart?
If I use command objects will this no longer be an issue?
I guess that would mean no simple adhoc SQL statements right?
like SELECT name from WHATEVER
would need a command object with
"SELECT @dotnet.itags.org.NAME, etc.
and then params
is this the way to solve the problem?
Thanks,
ShaneUse command objects. The single quote "problem" will go away.
Don't use ad-hoc SQL statements that are concatenated from user input. You
are leaving your application vulnerable to a SQL injection attack.
Colin
"SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> How can I handle the user entering single quotes like in
> Bob's mini mart?
> If I use command objects will this no longer be an issue?
> I guess that would mean no simple adhoc SQL statements right?
> like SELECT name from WHATEVER
> would need a command object with
> "SELECT @.NAME, etc.
> and then params
> is this the way to solve the problem?
> Thanks,
> Shane
Yes, use parameter objects.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> How can I handle the user entering single quotes like in
> Bob's mini mart?
> If I use command objects will this no longer be an issue?
> I guess that would mean no simple adhoc SQL statements right?
> like SELECT name from WHATEVER
> would need a command object with
> "SELECT @.NAME, etc.
> and then params
> is this the way to solve the problem?
> Thanks,
> Shane
OK. That is what I had thought.
So to do that in command ojbects I do something like.
dim cmd as new sqlCommand("SELECT Name,Address,City FROM tblPerson WHERE
State=@.State",conn)
is that right? And then just add @.State as a param?
I don't need to do the same for the output params right? LIke Name, Address
and City--or do I have to do them the same?
Shane
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:Og3zd2sSEHA.1168@.TK2MSFTNGP11.phx.gbl...
> Yes, use parameter objects.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
> news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> > How can I handle the user entering single quotes like in
> > Bob's mini mart?
> > If I use command objects will this no longer be an issue?
> > I guess that would mean no simple adhoc SQL statements right?
> > like SELECT name from WHATEVER
> > would need a command object with
> > "SELECT @.NAME, etc.
> > and then params
> > is this the way to solve the problem?
> > Thanks,
> > Shane
Basically correct.
Output parameters would need to be declared, but in your example, you
seem to be returning a recordset, not output parameters. This would
return a .NET dataset with multiple records which you could either
bind to an ASP control or use in whatever method you deem prudent :)
On Sun, 6 Jun 2004 09:49:15 -0500, "SStory"
<TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
>OK. That is what I had thought.
>So to do that in command ojbects I do something like.
>dim cmd as new sqlCommand("SELECT Name,Address,City FROM tblPerson WHERE
>State=@.State",conn)
>is that right? And then just add @.State as a param?
>I don't need to do the same for the output params right? LIke Name, Address
>and City--or do I have to do them the same?
>Shane
>
>"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>news:Og3zd2sSEHA.1168@.TK2MSFTNGP11.phx.gbl...
>> Yes, use parameter objects.
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://Steve.Orr.net
>>
>>
>> "SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
>> news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
>> > How can I handle the user entering single quotes like in
>>> > Bob's mini mart?
>>> > If I use command objects will this no longer be an issue?
>>> > I guess that would mean no simple adhoc SQL statements right?
>>> > like SELECT name from WHATEVER
>>> > would need a command object with
>>> > "SELECT @.NAME, etc.
>> > and then params
>>> > is this the way to solve the problem?
>>> > Thanks,
>>> > Shane
>>>>>
>
Thanks Dan,
Will try to go through and fix offending code.
Shane
"Dan Brussee" <dbrussee@.nc.rr.com> wrote in message
news:7ve6c0ls13v3k00iu79pbdf20ggd73m8tp@.4ax.com...
> Basically correct.
> Output parameters would need to be declared, but in your example, you
> seem to be returning a recordset, not output parameters. This would
> return a .NET dataset with multiple records which you could either
> bind to an ASP control or use in whatever method you deem prudent :)
>
> On Sun, 6 Jun 2004 09:49:15 -0500, "SStory"
> <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote:
> >OK. That is what I had thought.
> >So to do that in command ojbects I do something like.
> >dim cmd as new sqlCommand("SELECT Name,Address,City FROM tblPerson WHERE
> >State=@.State",conn)
> >is that right? And then just add @.State as a param?
> >I don't need to do the same for the output params right? LIke Name,
Address
> >and City--or do I have to do them the same?
> >Shane
> >"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> >news:Og3zd2sSEHA.1168@.TK2MSFTNGP11.phx.gbl...
> >> Yes, use parameter objects.
> >>
> >> --
> >> I hope this helps,
> >> Steve C. Orr, MCSD, MVP
> >> http://Steve.Orr.net
> >>
> >>
> >> "SStory" <TheStorys@.TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
> >> news:OzRbcimSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> >> > How can I handle the user entering single quotes like in
> >> >> > Bob's mini mart?
> >> >> > If I use command objects will this no longer be an issue?
> >> >> > I guess that would mean no simple adhoc SQL statements right?
> >> >> > like SELECT name from WHATEVER
> >> >> > would need a command object with
> >> >> > "SELECT @.NAME, etc.
> >> > and then params
> >> >> > is this the way to solve the problem?
> >> >> > Thanks,
> >> >> > Shane
> >> >> >> >>
> >
okay i got the user controls working
working fine. in fact, everything looks great, but the information
in the .aspx pages lays right on top of the user controls...
how do i orient the .aspx pages to fit around the user controls (ie
under and to the right of the header, and above the footer)? i could
manually move all the elements so that they fit, but then i might as
well just build the header right into all the pages...
(the include statements from the old, html pages had a table built
right into them where the pages loaded to avoid this. my new
"header"/user control also has this, if this helps)
could you guys please help? i appreciate all the help so far!what most of us do is somethign like what you said. Every page has this.
<table>
<tr>
<td colspan=2><header_here></td>
</tr>
<tr>
<td><left_menu></td>
<td>Page Info Goes Here</td>
</tr>
<tr>
<td colspan=2><footer_here></td>
</tr>
</table>
The controls you created for header/footer/menu are dropped onto each page
but you only have them in one location for modifying.
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"mglover" <maglover@.scgov-dot-net.no-spam.invalid> wrote in message
news:41013715$1_2@.mcse.ms...
> ok i've made my include statements into .ascx files and they are
> working fine. in fact, everything looks great, but the information
> in the .aspx pages lays right on top of the user controls...
> how do i orient the .aspx pages to fit around the user controls (ie
> under and to the right of the header, and above the footer)? i could
> manually move all the elements so that they fit, but then i might as
> well just build the header right into all the pages...
> (the include statements from the old, html pages had a table built
> right into them where the pages loaded to avoid this. my new
> "header"/user control also has this, if this helps)
> could you guys please help? i appreciate all the help so far!
>
Saturday, March 24, 2012
OLE DB Connections
Arvind
Hi,
does the aspnet_user account on your machine have write permissions on the folder where your access database resides?
Grz, Kris.
I've tried both suggestions and still no luck. I've also tried to connect with the Nothwinds database example by placing it in a variety of directories and I can't connect to it either. This is what I get:
Server Error in '/DBid' Application.
------------------------
The Microsoft Jet database engine cannot open the file 'C:\dbidmaster.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'C:\dbidmaster.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
Source Error:
Line 128: Dim dr As OleDb.OleDbDataReader
Line 129:
Line 130: OleDbConnection1.Open()
Line 131: dr = OleDbCommand1.ExecuteReader
Line 132:
Source File: c:\inetpub\wwwroot\DBid\Login.aspx.vb Line: 130
Stack Trace:
[OleDbException (0x80004005): The Microsoft Jet database engine cannot open the file 'C:\dbidmaster.mdb'. It is already opened exclusively by another user, or you need permission to view its data.]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
DBid.Login.btnSubmit_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\DBid\Login.aspx.vb:130
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
I think your *.mdb file was opened by the Microsoft Office Access
or, in your code you may not close the DataReader or the Connections last time
Thursday, March 22, 2012
OleDbConnection
I am just developing my first web application using asp.net and vb.net.
So far I have created a logon screen (which is a web form) where the user enters name and password and an OleDBConnection gets established. This works fine.
The question is now, how can I pass this connection the next page (web form). Do I have to use the session object or is there another mechanism I can use for this?
An example would be helpful.
Thanks in advance,
WolfgangKeeping connection string in Web.Config would be a better idea, probably encrypted and while using time you can decrypt or in Global.asax, you can call it and decrypt and keep in applicaiton variable and use it using Applicaiton variable where ever you need!
Ex: of web.config usage
http://aspnet.4guysfromrolla.com/articles/053102-1.aspx
Thanks for the quick reply and the example.
There are 2 problems I can see with this approach:
1. I am developing a multi-user application. When I keep the connectstring in Web.config, this is an application wide variable. At least username and password, which is part of the connect string, is not application specific, but user (session) specific. I cannot allow all my users to connect with the same username/password to the database. Any solution for that?
2. Keeping the connect string in Web.config would be fine, but would mean, that for each page a new database connection has to be established calling the open method. This takes time and if possible, I would like to avoid this.
regards,
Wolfgang
Friday, March 16, 2012
On Button click Print Form
Hi all,
In my asp.net page there is one form which is fill by user after filling form he will take the print out of that form
now how i canprint that form on button click and i want thatuser can not save and copy that formonly he can take print out of that form
after filling that from i am showing its all information in next page . how i can do underline task.
help me to perform this task
regard
happy Diwali
Perhaps you only allow the user print the webpage with print button and copy or save the content is not permitted .
In fact although you can disable the select, copy or save action with javascript, user can do some minor modification to html code to enable all the actions .
hi yyy8347
how i can print the form on button click
Easiest way is to call javascript method:
<input type="button" value="Print this page"onClick="window.print()">
how can you make the print button invisible...my problem is that the print button is included during printing
There are event that happen before and after the print is called on the page.. You can write code to hide/show the print button during those events..\
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onbeforeprint.asp
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onafterprint.asp
On Enter
I have the user enter a number in a text box and then click on the button to find & display the history.
Everything happens when they click on the button.
How do I make it happen if they hit the Enter key after typing in their number?
I want it to work both ways...hitting Enter or clicking the button.
Thanks!Reffer to this post :
http://www.vbforums.com/showthread.php?t=346036
Excellent!
This worked for me!
Thanks!
On Focus...
The textbox control does not have a GotFocus event os I am unsure on this.
ThanksThat is a client side event, You will have to use Javascript to do that.
Not GotFocus. It's onFocus.
In the onFocus event, call a client side javascript method that first compares the text in that textbox with 'Please enter username'. If they match, then set the textbox's value to an empty string. Else, let it be.
I suppose I should create an external js file for all the js code that will be coming in the days ahead.
Do you have an outline of the js event? I hate js. Should I pass the control name and its value to the procedure that is going to be called? or can it be done some other way?
And In case you just too lazy to write the function here is an example <asp:TextBox id="TextBox1" runat="server" value = "Please Enter Username" onFocus = "changeVal()"></asp:TextBox>
<script type="text/javascript" language="JavaScript">
function changeVal() {
if (document.Form1.TextBox1.value == "Please Enter Username")
document.Form1.TextBox1.value = "";
}
</script>
JS is quite loose. Shuja's shown you how to do this. In the case of this particular function, you wouldn't pass the control's name because it's just a matter of ONE control being processed. If it were a whole bunch of controls, you would pass 'this' as an argument.
Adding it to a .JS file is your discretion. You may want to start by having it on the same page itself at first and then move it all out later.
Look out for case sensitivity. It can invoke hours of debugging time.
I suppose I should create an external js file for all the js code that will be coming in the days ahead. You can put all Javascript in an external js file. Looks like a big ASP project is going on. :) Do you have an outline of the js event? I hate js. :eek: Now is the time that you start loving it. ;)
YES :( I have a large site to develop and I know just enough HTML/CSS to get by but I only did one small static site so far using asp.net. I want to learn it well. :)
The event doesnt seem to be firing :(
Btw, Thanks for the help so far guys. I will be posting many threads over the next week :(
<td style="BORDER-RIGHT: #b22222 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #b22222 1px solid; WIDTH: 140px; FONT-FAMILY: Verdana, Arial; ALIGN: center"
vAlign="top" align="center" bgColor="#eeeeee"><asp:textbox id="txtUsername" BackColor="#cccccc" style="FONT-SIZE: 12px; COLOR: #b22222" runat="server"
Width="110" value="Enter UserName" onFocus="changeVal()></asp:textbox>
<script type="text/javascript" language="JavaScript">
function changeVal() {
if (document.Form1.txtUsername.value == "Enter Username")
document.Form1.txtUsername.value = "";
}
</script>
</td>
Take a look at your code, you are setting the value to Enter UserName and then in the event you are checking for Enter Username
w00t w00t! I'm an ASP.NET programmer now :lol:
It was a stupid missing doublequote from the atuomatic formatting that the ide does. Also found that when it did fire it wasnt matching. I guess its case sensitive?
I didnt know you could place the js code in there that way. :thumb:
One more question...
When I click on the submit button I have it redirect to "#" for testing. When this happens the postback repopulates the login textbox.
Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Response.Redirect("#")
End Sub
Thats because ASP.NET has a different State Management that classic ASP. Read about state management on MSDN.
If you want this should not happen then set EnableViewState of the control to False.
Ok, thanks. I'll look it up. :)
I tried setting it to false in the page_load but if i type in a username and submit, it repopulates it with "Enter UserName" :(
You must be calling a function in the body onload that populates that textbox. Instead of calling the function in body load, send a call to it to the output using Page.RegisterStartupScript.
In your page load event:
If Not Page.IsPostBack
Page.RegisterStartupScript("myscript","nameofthefunction();")
End If
I did this in the page_load event procedure
If Page.IsPostBack = False Then
Me.txtUsername.Text = "Enter UserName"
End If
Me.txtUsername.EnableViewState() = FalseIt appears to work but I wont be 1000% until I finish creating the db and writting the login code.
Does this look correct now? I did have the textbox being populated in the aspx element tag in the html section.
It'll do.
Thanks :)
Actually if you had done your response.redirect to the name of the page "default.aspx" for example, it would not have retained the settings.
When you redirect to an anchor, it instead of redirecting the page just sends the browser a different URL, but maintains state. It does this to help, not hinder, your coding.
Just letting you know that you just killed the proverbial fly with an elephant gun.
Well I like overkill but I just dont have a second page to redirect to yet. I'll test it out with a dummy page.
the second page I speak of is the same page.
Lets say the "test" page was called "test.aspx" then what I was saying is instead of redirecting to "#" you redirect to "test.aspx" (which is the same page).
I'm still new to asp.net but I did redirect to the same page and it didnt retain the login name I used. It repopulated it with the "Enter UserName" again. Is this what you meant?
When it goes to a secondary page it shouldnt be populated at all since they will already be logged in.
Ok, related issue still here. The login txtUserName textbox contents should be added to the User_Name session variable but its not retaining or able to even be placed into a label control. :(
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Login code
If Session.SessionID Is Nothing Then
'code to alert or redirect to login in again
Response.Redirect("index.aspx")
End If
If Session.Item("sesUser_Name") = Nothing Then
Session.Add("sesUser_Name", "RobDog888")
End If
If Page.IsPostBack = False Then
Me.txtUsername.Text = "Enter UserName"
End If
Me.txtUsername.EnableViewState() = False
End Sub
Maybe you left it out accidentally but it does not look like you are inserting the contents of the sesson variable anyway :)
Something like:
If Session.Item("sesUser_Name") = Nothing Then
Session.Add("sesUser_Name", "RobDog888")
Else
If Page.IsPostBack = False Then
Me.txtUsername.Text = "Enter UserName"
Else
Me.txtUsername.Text = Session.Item("sesUser_Name")
end if
end if
?
Sorry, forgot to post the btnLogin click code. RobDog888 was a test. Like a temp guest user id.
Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Session.Item("User_Name") Is Nothing Then
Session.Add("User_Name", Me.txtUsername.Text)
End If
Me.lblUserName.Text = Session.Item("User_Name").ToString 'THIS IS NOT POULATING MY LABEL :(
Session.Timeout = 15
'...
End Sub
Btw, thats a really nice looking forums site in your sig. vBull 3.5 :)
is btnLogin your submit button? If so I recommend placing that code in the page load event. Check if you have a username posted and if so add it as a session variable. Elseif check if a session variable is already present and if so place it in the text box.
Then again, I could just be showing my ignorance of ASP.NET. Sorry :(
This is the home page so to be able to login only once and access the secured pages it needs to check on the page load for if they just refresh or renav to the home page after they already logged in. Now if they havent logged in at all then the pageload will not have a txtUserName content to load into the session var. It needs to ignore the "Enter UserName" auto text htat I had populated in the js in the html for the page as shown by Shuja Alis posted code.
So it seems that when the postback happens it doesnt pickup the session var. :(
w00t, got it. It was the stupid Session.SessionID check that was throwing it off. This now retains the uisername (without any verification of login yet) and populates a label control with the username and starts the session timeout of 15 minutes and redirects with SSL. :D
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session.Item("User_Name") = Nothing Then
Session.Add("User_Name", "Guest")
End If
If Page.IsPostBack = False Then
Me.txtUsername.Text = "Enter UserName"
End If
Me.txtUsername.EnableViewState() = False
End Sub
Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Session.Item("User_Name") Is Nothing Then
Session.Add("User_Name", Me.txtUsername.Text)
End If
Me.lblUserName.Text = Session.Item("User_Name").ToString
Session.Timeout = 15
Response.Redirect("https://secure.blah.com")
End SubNow I just need to clear the txtUserName box and clear the lblUserName upon page load to take out the control name thats in it by default.
another step closer. :)
Glad to not be of assistance :D
But a second set of eyes is always a help. :) I noticed that when you reposted my code my sesUser_Name var was named differently then it was in the btnLogin clck event. ;)
Now I am multi-tasking and in the middle of creating the users sql table.
Thanks everyone :thumb:
But a second set of eyes is always a help. :) I noticed that when you reposted my code my sesUser_Name var was named differently then it was in the btnLogin clck event. ;)
Now I am multi-tasking and in the middle of creating the users sql table.
Thanks everyone :thumb:
You are still here. :eek:
I though you would have finished your project by now. :)
All the best. :thumb:
Thanks but unfortunately I am a noob at asp.net so its going to take some time. :(
Ps, I have 5 or 6 hours left to finish the entire login and security part. :cry:
On page_EXIT ??
I mean, if the user clicks in any other link available on the screen, i
would like to caught thta event and pop-up , remembering to save
unsaved data...
is that possible??
Thanks
AlbertoAre you looking for Page.OnUnload ?
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/
======================================
"Gordowey" <albertoiriarte@.gmail.com> wrote in message
news:1130431340.421969.246570@.o13g2000cwo.googlegr oups.com...
> Is there an event fired when I exit from an aspx.page?
> I mean, if the user clicks in any other link available on the screen, i
> would like to caught thta event and pop-up , remembering to save
> unsaved data...
> is that possible??
> Thanks
> Alberto
Unfortunately, there is no such thing. Since the browser is completely
disconnected from the server immediately after it loads the last item
required for that page, there's no way to trap this. You would have to so
something like create an onclick hander for each anchor on the page that
would fire some script to remind them, perhaps a message box that reminds
them and forces them to click yes to continue and leave or no and not be
redirected.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Gordowey" <albertoiriarte@.gmail.com> wrote in message
news:1130431340.421969.246570@.o13g2000cwo.googlegr oups.com...
> Is there an event fired when I exit from an aspx.page?
> I mean, if the user clicks in any other link available on the screen, i
> would like to caught thta event and pop-up , remembering to save
> unsaved data...
> is that possible??
> Thanks
> Alberto
oK thanks..thats what I thouht...its hard...put an event in each
link...
thanks!
Alberto
Hi, Mark.
according to ASP.NET 2.0 Internals :
http://msdn.microsoft.com/library/d...l/internals.asp
there *is* a Page.OnUnload event and it's a part
of the Page Lifecycle methods ( see Table 1).
Wouldn't that event do for what he apparently wants to do ?
Page.Unload inherits from Control :
http://msdn.microsoft.com/library/d...emberstopic.asp
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/
======================================
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:eEaKtax2FHA.2268@.TK2MSFTNGP15.phx.gbl...
> Unfortunately, there is no such thing. Since the browser is completely disconnected from
> the server immediately after it loads the last item required for that page, there's no
> way to trap this. You would have to so something like create an onclick hander for each
> anchor on the page that would fire some script to remind them, perhaps a message box
> that reminds them and forces them to click yes to continue and leave or no and not be
> redirected.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Gordowey" <albertoiriarte@.gmail.com> wrote in message
> news:1130431340.421969.246570@.o13g2000cwo.googlegr oups.com...
>> Is there an event fired when I exit from an aspx.page?
>>
>> I mean, if the user clicks in any other link available on the screen, i
>> would like to caught thta event and pop-up , remembering to save
>> unsaved data...
>>
>> is that possible??
>>
>> Thanks
>>
>> Alberto
Not server side (the server would do once the page is navigated away).
But you could perhaps use the onbeforeunload client side event :
http://msdn.microsoft.com/library/d...eforeunload.asp
--
Patrice
"Gordowey" <albertoiriarte@.gmail.com> a crit dans le message de
news:1130432315.940034.103810@.f14g2000cwb.googlegr oups.com...
oK thanks..thats what I thouht...its hard...put an event in each
link...
thanks!
Alberto
You must come from a windows forms world. While it sounds like the
right event, and it would be if we we're using a windows form, OnUnload
fires before a page is sent back to the user. It goes something like
this:
Client Request --> OnLoad --> Some more events -->OnUnload --> Response
back to client
Hooking into the OnUnload event simply allows you to do stuff as a last
step before a rendered page is sent back to the client.
As another poster mentioned, you could hook into the javascript
onbeforeunload event with something like this:
<script>
function CheckUnload()
{
if (("1" == document.forms["Form1"].IsChanged.Value))
{
if (confirm("You have unsaved changes. Click OK to save changes."))
{
document.forms["Form1"].submit();
alert("Changes saved.");
return false;
}
}
}
</script
<body onbeforeunload="CheckUnload()">...
Best of luck,
Matt Furnari
Thanks Patrice, that link helps me a lot...
unfortunatelly this systema must be developed in webforms...not
winforms...)
Thanks ALL@.@.
That still wouldn't work if the user just closes the browser or types a new
web address into the address bar, selects a favorite, etc.
The only reliable way I know of is to handle the onbeforeunload event in the
browser. In this handler, you then prompt the user to cancel the operation,
and maybe make a server side call to save the data. However, the caveat is
that this event fires even if the user is just navigating to the next
logical page in your application via a link or button. So, you have to have
code that keeps track of what the user has been doing, so your handler knows
if this event is being called because the user is actually trying to close
your application, or just because the user is making a request via some
functionality in your application, and so the current page is being
unloaded.
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:eEaKtax2FHA.2268@.TK2MSFTNGP15.phx.gbl...
> Unfortunately, there is no such thing. Since the browser is completely
> disconnected from the server immediately after it loads the last item
> required for that page, there's no way to trap this. You would have to so
> something like create an onclick hander for each anchor on the page that
> would fire some script to remind them, perhaps a message box that reminds
> them and forces them to click yes to continue and leave or no and not be
> redirected.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Gordowey" <albertoiriarte@.gmail.com> wrote in message
> news:1130431340.421969.246570@.o13g2000cwo.googlegr oups.com...
>> Is there an event fired when I exit from an aspx.page?
>>
>> I mean, if the user clicks in any other link available on the screen, i
>> would like to caught thta event and pop-up , remembering to save
>> unsaved data...
>>
>> is that possible??
>>
>> Thanks
>>
>> Alberto
>>
re:
> You must come from a windows forms world.
heh, heh... I don't.
It's just that it's *really* hard to bat for 1.000.
Baseball players win batting championships with .310 batting averages.
This league is a little tougher than that.
;-)
Thanks...
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/
======================================
"sp3d2orbit" <mfurnari@.gmail.com> wrote in message
news:1130434360.479309.211030@.o13g2000cwo.googlegr oups.com...
> You must come from a windows forms world. While it sounds like the
> right event, and it would be if we we're using a windows form, OnUnload
> fires before a page is sent back to the user. It goes something like
> this:
> Client Request --> OnLoad --> Some more events -->OnUnload --> Response
> back to client
> Hooking into the OnUnload event simply allows you to do stuff as a last
> step before a rendered page is sent back to the client.
> As another poster mentioned, you could hook into the javascript
> onbeforeunload event with something like this:
> <script>
> function CheckUnload()
> {
> if (("1" == document.forms["Form1"].IsChanged.Value))
> {
> if (confirm("You have unsaved changes. Click OK to save changes."))
> {
> document.forms["Form1"].submit();
> alert("Changes saved.");
> return false;
> }
> }
> }
> </script>
> <body onbeforeunload="CheckUnload()">...
>
> Best of luck,
> Matt Furnari
This is *not* Windows forms. I don't really like the ambigious webform term.
A webform runs server side to produce an HTML output that is transmited and
rendered client side. This event is a client side event that can be handle
within this HTML page to be warn when the user is about to navigate way from
its current browser window.
In a web application, "web pages" have a double personality : they have a
representation on the server (as .NET code rendering HTML code) but you can
also handle a number of things client side from the produced HTML page
(DHTML/JavaScript).
--
Patrice
"Gordowey" <albertoiriarte@.gmail.com> a crit dans le message de
news:1130435385.042534.258600@.g14g2000cwa.googlegr oups.com...
> Thanks Patrice, that link helps me a lot...
> unfortunatelly this systema must be developed in webforms...not
> winforms...)
> Thanks ALL@.@.
This is a problem for all web applications.
If I have a complicated application where items are saved and updated
on mulitple pages, I save all work the user has done immediately. You
cannot assume that you can save the user's work at a another point in
time. Even if you captured every link,you can't control when the user
closes the web brower (I do it accidently all the time) or hits the
back button.
On page_EXIT ??
I mean, if the user clicks in any other link available on the screen, i
would like to caught thta event and pop-up , remembering to save
unsaved data...
is that possible'
Thanks
AlbertoAre you looking for Page.OnUnload ?
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/
======================================
"Gordowey" <albertoiriarte@.gmail.com> wrote in message
news:1130431340.421969.246570@.o13g2000cwo.googlegroups.com...
> Is there an event fired when I exit from an aspx.page?
> I mean, if the user clicks in any other link available on the screen, i
> would like to caught thta event and pop-up , remembering to save
> unsaved data...
> is that possible'
> Thanks
> Alberto
>
Unfortunately, there is no such thing. Since the browser is completely
disconnected from the server immediately after it loads the last item
required for that page, there's no way to trap this. You would have to so
something like create an onclick hander for each anchor on the page that
would fire some script to remind them, perhaps a message box that reminds
them and forces them to click yes to continue and leave or no and not be
redirected.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Gordowey" <albertoiriarte@.gmail.com> wrote in message
news:1130431340.421969.246570@.o13g2000cwo.googlegroups.com...
> Is there an event fired when I exit from an aspx.page?
> I mean, if the user clicks in any other link available on the screen, i
> would like to caught thta event and pop-up , remembering to save
> unsaved data...
> is that possible'
> Thanks
> Alberto
>
oK thanks..that=B4s what I thouht...it=B4s hard...put an event in each
link...
thanks!
Alberto
Hi, Mark.
according to ASP.NET 2.0 Internals :
http://msdn.microsoft.com/library/d...br />
nals.asp
there *is* a Page.OnUnload event and it's a part
of the Page Lifecycle methods ( see Table 1).
Wouldn't that event do for what he apparently wants to do ?
Page.Unload inherits from Control :
http://msdn.microsoft.com/library/d...emberstopic.asp
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/
======================================
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:eEaKtax2FHA.2268@.TK2MSFTNGP15.phx.gbl...
> Unfortunately, there is no such thing. Since the browser is completely dis
connected from
> the server immediately after it loads the last item required for that page
, there's no
> way to trap this. You would have to so something like create an onclick ha
nder for each
> anchor on the page that would fire some script to remind them, perhaps a m
essage box
> that reminds them and forces them to click yes to continue and leave or no
and not be
> redirected.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Gordowey" <albertoiriarte@.gmail.com> wrote in message
> news:1130431340.421969.246570@.o13g2000cwo.googlegroups.com...
Not server side (the server would do once the page is navigated away).
But you could perhaps use the onbeforeunload client side event :
http://msdn.microsoft.com/library/d...eforeunload.asp
Patrice
"Gordowey" <albertoiriarte@.gmail.com> a crit dans le message de
news:1130432315.940034.103810@.f14g2000cwb.googlegroups.com...
oK thanks..thats what I thouht...its hard...put an event in each
link...
thanks!
Alberto
You must come from a windows forms world. While it sounds like the
right event, and it would be if we we're using a windows form, OnUnload
fires before a page is sent back to the user. It goes something like
this:
Client Request --> OnLoad --> Some more events -->OnUnload --> Response
back to client
Hooking into the OnUnload event simply allows you to do stuff as a last
step before a rendered page is sent back to the client.
As another poster mentioned, you could hook into the javascript
onbeforeunload event with something like this:
<script>
function CheckUnload()
{
if (("1" == document.forms["Form1"].IsChanged.Value))
{
if (confirm("You have unsaved changes. Click OK to save changes."))
{
document.forms["Form1"].submit();
alert("Changes saved.");
return false;
}
}
}
</script>
<body onbeforeunload="CheckUnload()">...
Best of luck,
Matt Furnari
Thanks Patrice, that link helps me a lot...
unfortunatelly this systema must be developed in webforms...not
winforms...)
Thanks ALL@.@.
That still wouldn't work if the user just closes the browser or types a new
web address into the address bar, selects a favorite, etc.
The only reliable way I know of is to handle the onbeforeunload event in the
browser. In this handler, you then prompt the user to cancel the operation,
and maybe make a server side call to save the data. However, the caveat is
that this event fires even if the user is just navigating to the next
logical page in your application via a link or button. So, you have to have
code that keeps track of what the user has been doing, so your handler knows
if this event is being called because the user is actually trying to close
your application, or just because the user is making a request via some
functionality in your application, and so the current page is being
unloaded.
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:eEaKtax2FHA.2268@.TK2MSFTNGP15.phx.gbl...
> Unfortunately, there is no such thing. Since the browser is completely
> disconnected from the server immediately after it loads the last item
> required for that page, there's no way to trap this. You would have to so
> something like create an onclick hander for each anchor on the page that
> would fire some script to remind them, perhaps a message box that reminds
> them and forces them to click yes to continue and leave or no and not be
> redirected.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Gordowey" <albertoiriarte@.gmail.com> wrote in message
> news:1130431340.421969.246570@.o13g2000cwo.googlegroups.com...
>
re:
> You must come from a windows forms world.
heh, heh... I don't.
It's just that it's *really* hard to bat for 1.000.
Baseball players win batting championships with .310 batting averages.
This league is a little tougher than that.
;-)
Thanks...
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/
======================================
"sp3d2orbit" <mfurnari@.gmail.com> wrote in message
news:1130434360.479309.211030@.o13g2000cwo.googlegroups.com...
> You must come from a windows forms world. While it sounds like the
> right event, and it would be if we we're using a windows form, OnUnload
> fires before a page is sent back to the user. It goes something like
> this:
> Client Request --> OnLoad --> Some more events -->OnUnload --> Response
> back to client
> Hooking into the OnUnload event simply allows you to do stuff as a last
> step before a rendered page is sent back to the client.
> As another poster mentioned, you could hook into the javascript
> onbeforeunload event with something like this:
> <script>
> function CheckUnload()
> {
> if (("1" == document.forms["Form1"].IsChanged.Value))
> {
> if (confirm("You have unsaved changes. Click OK to save changes."))
> {
> document.forms["Form1"].submit();
> alert("Changes saved.");
> return false;
> }
> }
> }
> </script>
> <body onbeforeunload="CheckUnload()">...
>
> Best of luck,
> Matt Furnari
>
on page refresh event fires again?
I have a ASP:Button which when clicked saves some data in the database. This works fine! But after the save if user refreshes the browser by hitting F5 or clicking the refresh button on the browser the event fires again and saves the data in the DB. How do I stop this??Clear the form of any values. Alternatively, when the user fills in values in the form, take him to another page which does the saving, then go back to the original form, clear of values. Or, move the user to another page after saving their data. A confirmation page, so to speak.