Showing posts with label forms. Show all posts
Showing posts with label forms. Show all posts

Thursday, March 29, 2012

Passing values between forms

(Type your message here)
Hi
I'm new to asp.net and I need some help
I have three forms with some textboxes.I want to pass the values of the text
boxes of form1 and form2 to the third form
For this I'm using in the first form
System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
also a get function for returning the values of textbox
In the second form
rp1 = CType(context.Current.Handler, firstform)
RegisterHiddenField("txtpjcode", Request("txtpjcode"))
similarly for the second form
But When I run this I can't retrive any values of previous forms
From: Mani P.S
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>vrL66fQqLUe3kVkG/raHIA==</Id>Hi,
see this in MSDN
http://msdn.microsoft.com/library/d...bformspages.asp
HTH
Regards
Joyjit
"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> --
> From: Mani P.S
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id>
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)
'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")
Then, in WebForm2.aspx:
'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)
Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://www.dotnetbips.com/displayarticle.aspx?id=79
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
> textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> --
> From: Mani P.S
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id>

Passing values between forms

(Type your message here)
Hi
I'm new to asp.net and I need some help
I have three forms with some textboxes.I want to pass the values of the textboxes of form1 and form2 to the third form
For this I'm using in the first form
System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
also a get function for returning the values of textbox
In the second form
rp1 = CType(context.Current.Handler, firstform)
RegisterHiddenField("txtpjcode", Request("txtpjcode"))
similarly for the second form
But When I run this I can't retrive any values of previous forms

----------
From: Mani P.S

--------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>vrL66fQqLUe3kVkG/raHIA==</Id>Hi,

see this in MSDN
http://msdn.microsoft.com/library/d...bformspages.asp

HTH
Regards

Joyjit

"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> ----------
> From: Mani P.S
> --------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79

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

"Mani P.S via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:u1OdS1pNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> (Type your message here)
> Hi
> I'm new to asp.net and I need some help
> I have three forms with some textboxes.I want to pass the values of the
> textboxes of form1 and form2 to the third form
> For this I'm using in the first form
> System.Web.HttpContext.Current.Server.Transfer("secondform.aspx")
> also a get function for returning the values of textbox
> In the second form
> rp1 = CType(context.Current.Handler, firstform)
> RegisterHiddenField("txtpjcode", Request("txtpjcode"))
> similarly for the second form
> But When I run this I can't retrive any values of previous forms
> ----------
> From: Mani P.S
> --------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>vrL66fQqLUe3kVkG/raHIA==</Id

Passing values between pages using Forms Authentication

I want to know how can i pass a value from my database to another page using Forms Authentication.

In this example:

1Sub Logon_Click(ByVal senderAs Object,ByVal eAs EventArgs)Handles Submit1.Click23Dim objConnectionAs Data.SqlClient.SqlConnection4Dim objCommandAs Data.SqlClient.SqlCommand5Dim usernameAs String6 Dim passwordAs String7 Dim strSQLQueryAs String8 Dim RecordCountAs Integer910 username = userTextBox.Text11 password = passTextBox.Text1213If Len(Trim(username)) > 0Then14 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _15 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _16 &"Connect Timeout=15;")1718 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "19 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)202122 Try23 objConnection.Open()24 RecordCount = CInt(objCommand.ExecuteScalar())25 Catch ex As Exception26 Finally27 objConnection.Close()28 End Try2930 If RecordCount = 0 Then31 Msg.Text = "Identificação de conserto ou código de acesso inválido."32Else33 FormsAuthentication.RedirectFromLoginPage _34 (userTextBox.Text, Persist.Checked)35End If3637 objConnection.Close()38End If394041 End Sub42

I want to store the value of the field named <numero> of the database, and when the user authenticates, i want to print that variable in the default.aspx page.

You can use a Session variable to do so. If you are using ASP.NET 2.0, then you could use a Profile object too.

Does this help?

Regards


i've just tried to use sessions, but when the user autheticates and are redirected to the default.aspx page, it lost the session value.

1 username = userTextBox.Text2 password = passTextBox.Text3 Session("USERNAME") = username45If Len(Trim(username)) > 0Then6 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _7 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _8 &"Connect Timeout=15;")910 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "11 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)121314 Try15 objConnection.Open()16 RecordCount = CInt(objCommand.ExecuteScalar())17 Catch ex As Exception18 Finally19 objConnection.Close()20 End Try2122 If RecordCount = 0 Then23 Msg.Text = "Identificação de conserto ou código de acesso inválido."24Else2526 FormsAuthentication.RedirectFromLoginPage _27 (userTextBox.Text, Persist.Checked)

in this code in the default.aspx it doesn't display any value.

1Sub Page_Load(ByVal SrcAs Object,ByVal eAs EventArgs)2 userLabel.Text = Session("USERNAME")3End Sub4

why?

Passing values between Web Forms

Hi,

I have a web page which is split vertically into two by a frame, giving me LeftPage.aspx and RightPage.aspx.

Now then, I want to pass the contents of a few text boxes on LeftPage to some text boxes on RightPage.

How do I do it?

By the way, i'd like the passing to happen at the end of the Page_Load event on LeftPage.

Cheers,
DarrenHello, in the LeftFrame, you specify the link as follows:

Then you name the right frame = "rightFrame". Then, you have used querystrings to pass these values.

regards
Hi,

Thanks for the quick response, however your message does not show any code between your first line and then the line that starts "Then you name..." (i.e. it's blank).

Sorry i'm as thick as a whale omlette when it comes to APS.NET i've only just started... could you be more specific please (i.e. supply code??)

thanks in advance!

regards,
darren
By the way i've tried:

LEFT PAGE CODE:

Server.Transfer("RightPage.aspx")

... but this replaces the left page with the right page inside the left frame!!

regards,
darren


Link text

Replace the 'this' and 'that' with asp variables, or databinders, whatever it is you are using as the values.
Well, I beleive this is the same as my solution, but I didn't get any resposne ?

regards
Use the code that chrisbarr mentioned for the link.
Then in the rightpage.aspx code, use something like (in VB)

If Not Request.Params("a") Is Nothing Then
info = Request.Params("a")
End If

This should collect the information.
Does this help?

Passing Values Between web forms pages

i am trying to implement passing values from my login webpage to another. but i get an error of "Specified cast is not valid."

i followed the program logic and I cant find the error that the debugger says that it is in the casting. I am following the example provided by Microsoft in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

next, it is the code behind of both forms

1st webform

<---login.aspx---
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
Public ReadOnly Property UserId() As String
Get
Return Trim(txtUser.Text)
End Get
End Property

Private Sub lnkLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkLogin.Click

Server.Transfer("secondForm.aspx")

end sub

<----secondForm.aspx---
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web

Imports System.Web.Security
Imports System.Web.UI

Public Class secondForm

Inherits System.Web.UI.Page

Public userLogin As login

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim blnAddinProgress As Boolean

Dim strUsername As String

If Not IsPostBack() Then

userLogin = CType(Context.Handler, login)

strUsername = userLogin.UserId

<-----
The error that i got from the debugger is "Specified cast is not valid."

following this message, Do i have to change the casting or is there another error or piece of code that i am forgetting.

thanks in advanceYou might try the similar technique documented in this topic:

Passing Values Between Web Forms Pages
HI! the link that you provided me is the one that i used.

If you see the structure of the code is pretty simmilar to the one of the link. Do you know about other option?
the error could be related to I am using Forms authentications?

thank you very much for your help
>HI! the link that you provided me is the one that i used.

Ok. The URL that you provided is not the same as the one for the other article, so I was a little confused.

Here's a question: what kind of control is lnkLogin in your login page? It should be a LinkButton or just Button (not a Hyperlink).

So, assuming that you're using a LinkButton, the bad news is that I cannot reproduce your error. I had to add a line (which you probably have). This is what my target page code looks like:

 Public userLogin As login
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim blnAddinProgress As Boolean
Dim strUsername As String
If Not IsPostBack() Then
userLogin = CType(Context.Handler, login)
strUsername = userLogin.UserId
Response.Write(strUsername)
End If
End Sub

Passing Values Between Web Forms Pages

I am porting an old client/server application to asp.net. I used to
retrieve data into local tables (Paradox table-files on the client's
disk) and work on them before saving them back to the server. What is
the approach for this in asp.net? The comments in MSDN on using the
session object are scary, imagining that several users at the same
time will use plenty of space on the server's memory! Or is it
realistic to memorize the data in a page and access them from the
following pages?
Thank for your help!You can add objects to the HttpContext of the current Page, and then use
Server.Transfer to transfer to the next page. The HttpContext is transferred
as well, and you can pull the data from the original page out of that.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutori...?tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

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

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
There are a lot of options to transferring values between pages: Session
like you've mentioned, The querystring (of course), But you may want to look
into Server.Transfer and the Context Object.

I hope this leads you in the right direction.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Actually what I want to transfer between forms is huge tables... do
you think it is appropriate to use the server.transfer?

cgian31@.katamail.com (cgia) wrote in message news:<b35db8fd.0307250620.7aed635b@.posting.google.com>...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Yes, that seems like one of the more efficient solutions for this particular
problem.

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

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307251918.2ad13d06@.posting.google.c om...
> Actually what I want to transfer between forms is huge tables... do
> you think it is appropriate to use the server.transfer?
>
> cgian31@.katamail.com (cgia) wrote in message
news:<b35db8fd.0307250620.7aed635b@.posting.google.com>...
> > I am porting an old client/server application to asp.net. I used to
> > retrieve data into local tables (Paradox table-files on the client's
> > disk) and work on them before saving them back to the server. What is
> > the approach for this in asp.net? The comments in MSDN on using the
> > session object are scary, imagining that several users at the same
> > time will use plenty of space on the server's memory! Or is it
> > realistic to memorize the data in a page and access them from the
> > following pages?
> > Thank for your help!

Monday, March 26, 2012

Passing Variable Across Secure Pages

Hey Bros:

I'm new to asp.net obviously, and am working on trying to put together my first website. I need help passing variables across multiple forms then trying to query a sql database based on the data which is passed.

What I have is
page one, datalist with a button when clicked will redirect to a page in a directory protected using forms authentication, user will be redirected to log in, once logged in the are redirected to the original destination page.

page two, will show the items, and details of the page which corresponds to the button the visitor originally choose.

I know I basicly have to create something to grab the value on the original page, and then on the destination page create something to grab the value, then perform an SQL statement agianst the value which was orignally grabbed from the first page. I just cannot find code which I can understand to do this. Any help would be greatly appreciated!Well one step at a time will take you far places...

You can easily preserve the data in a form item by enabling viewstate on the form by adding the following syntax enabledviewstate="true" This uses more system resources though and should not be enabled for form items that do not need it.

You were saying that you want to pass data from here to there etc... Well in asp.net you really do not have to and can code your entire program into one asp.net which eliminates passing values to and from. Ever hear about asp.net panels? A good book I would recommend is ASP.NET UNLEASHED by: Stephen Walther, if you are just starting out... I will track this thread to see if you have any other Q's...

Saturday, March 24, 2012

Passing Variables between web forms

Hi There,
My question is as following,
I have a webform (Webform1) which contains one label control and command
button, when the user clicks the button another webform (Webform2) appears,
webform2 contains only one control which is the Calendar control, I want to
do the following
1- when the user selects a date from the webforms, I want the value
(selected date) appears in the label control in the webform1
2- Webform2 to be closed automatically after the date selection
Kind regards and thanks in advancesearch MSDN for showModalDialog method. That will do just what you're
looking for.
Dale
"Aitham alama" <h_salama@.yahoo.com> wrote in message
news:eSfH8gcZEHA.3716@.TK2MSFTNGP11.phx.gbl...
> Hi There,
> My question is as following,
> I have a webform (Webform1) which contains one label control and command
> button, when the user clicks the button another webform (Webform2)
appears,
> webform2 contains only one control which is the Calendar control, I want
to
> do the following
> 1- when the user selects a date from the webforms, I want the value
> (selected date) appears in the label control in the webform1
> 2- Webform2 to be closed automatically after the date selection
> Kind regards and thanks in advance
>

Passing Variables between web forms

Hi There,

My question is as following,

I have a webform (Webform1) which contains one label control and command
button, when the user clicks the button another webform (Webform2) appears,
webform2 contains only one control which is the Calendar control, I want to
do the following

1- when the user selects a date from the webforms, I want the value
(selected date) appears in the label control in the webform1
2- Webform2 to be closed automatically after the date selection

Kind regards and thanks in advancesearch MSDN for showModalDialog method. That will do just what you're
looking for.

Dale

"Aitham alama" <h_salama@.yahoo.com> wrote in message
news:eSfH8gcZEHA.3716@.TK2MSFTNGP11.phx.gbl...
> Hi There,
> My question is as following,
> I have a webform (Webform1) which contains one label control and command
> button, when the user clicks the button another webform (Webform2)
appears,
> webform2 contains only one control which is the Calendar control, I want
to
> do the following
> 1- when the user selects a date from the webforms, I want the value
> (selected date) appears in the label control in the webform1
> 2- Webform2 to be closed automatically after the date selection
> Kind regards and thanks in advance