Showing posts with label means. Show all posts
Showing posts with label means. Show all posts

Thursday, March 29, 2012

Newbie : Form question !

Hi,
I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla
So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields
Do I have to add a hidden field to store the blabla ?
Thanks for your help
Stanyou can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..
Regards,
Augustin
"Stan SR" <stan@.pasdepam.netsunset.com> wrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I use a Unique Identifier data for my website that I get using the
> Request["sid"]
> That means most of my links are formatted like mypage.aspx?sid=blabla
> So, I need to understand how to add the "?sid=blabla" onto a page where I
> have a form with several fields
> Do I have to add a hidden field to store the blabla ?
>
> Thanks for your help
> Stan
>
>
>
Yes. I have no doubt about this, but how to set the variable as a
queryString parameter when a page is Loaded ?
here's my case :
<form id="form1" runat="server>
<asp:CheckBox id="b" runat="server" text="test" />
</form>
In my codeBehind, I check if a "sid" url parameter is transmitted.
If not I generate one.
And I would like to place it a url parameter.
When I look at the source, I get this
<form name="form1" method="post" action="mypage.aspx" id="form1">
<input id="b" name="b"><label for "b">test</label>
</form>
What I need is to get
<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">
Stan
"Augustin Prasanna"
> you can either add a querystring or have a hidden field (having method as
> 'Get' will add all the form fields as querystring parameters)..
> Regards,
> Augustin
> "Stan SR" <stan@.pasdepam.netsunset.com> wrote in message
> news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
>
> What I need is to get
> <form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">[/colo
r]
You could set this in Page.Form.Attributes or use the PostBackUrl
property of your submit button to send the form to the new URL.
Tim

Newbie : Form question !

Hi,

I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla

So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields

Do I have to add a hidden field to store the blabla ?

Thanks for your help

Stanyou can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..

Regards,
Augustin

"Stan SR" <stan@.pasdepam.netsunset.comwrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Hi,
>
I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla
>
So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields
>
Do I have to add a hidden field to store the blabla ?
>
>
Thanks for your help
>
Stan
>
>
>
>
>


Yes. I have no doubt about this, but how to set the variable as a
queryString parameter when a page is Loaded ?

here's my case :

<form id="form1" runat="server>
<asp:CheckBox id="b" runat="server" text="test" />
</form>

In my codeBehind, I check if a "sid" url parameter is transmitted.
If not I generate one.
And I would like to place it a url parameter.

When I look at the source, I get this

<form name="form1" method="post" action="mypage.aspx" id="form1">
<input id="b" name="b"><label for "b">test</label>
</form>

What I need is to get
<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">

Stan

"Augustin Prasanna"

Quote:

Originally Posted by

you can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..
>
Regards,
Augustin
>
"Stan SR" <stan@.pasdepam.netsunset.comwrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>I use a Unique Identifier data for my website that I get using the
>Request["sid"]
>That means most of my links are formatted like mypage.aspx?sid=blabla
>>
>So, I need to understand how to add the "?sid=blabla" onto a page where I
>have a form with several fields
>>
>Do I have to add a hidden field to store the blabla ?
>>
>>
>Thanks for your help
>>
>Stan
>>
>>
>>
>>
>>


>
>


What I need is to get

Quote:

Originally Posted by

<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">


You could set this in Page.Form.Attributes or use the PostBackUrl
property of your submit button to send the form to the new URL.

Tim

Thursday, March 22, 2012

Newbie in ASP(not advanced by any means)

Hey everyone, I'm trying to use Session Variables for the first time. I just have a couple of questions, when I debub(Step Thru) the code--is there a way to tell what value they hold?

Secondly, without makin a class is the following code going to do it's purpose and function correctly. I'm taking the userid and password and I want to check against a SQL table called User--All my information in three tables I want to store in Session variables. I'm drawing everything through stored procedures. I would prefer you resond to my actual email address until I'm back at work on Friday(if not dont' worry about it i'll eventually see what you posted back):


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
Session("User") = ""
Session("empID") = ""
Session("SuperEmpID") = ""
Session("deptID") = ""
Session("currPeriod") = ""
Session("companyID") = ""
Session("facilityID") = ""
Session("Shift") = 0
Session("userName") = ""
Session("Role") = ""

End Sub

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim dataReader As SqlDataReader
Dim strPass, strUser As String

'Session("strUser") = txtUserID.Text
strUser = txtUserID.Text
strPass = txtPassword.Text

If strUser = "" Or strPass = "" Then
Response.Redirect("LogIn.aspx")
lblError.Text = "Your UserID or Password were incorrect. Please Try Again!"
End If

SqlCommand1.Parameters.Add(New SqlParameter("@dotnet.itags.org.strUser", strUser))
SqlCommand1.Parameters.Add(New SqlParameter("@dotnet.itags.org.strPass", strPass))

'Opens the connection to the DB
SqlConnection2.Open()

'Reads the data entered against SQL DB records
dataReader = SqlCommand1.ExecuteReader()

While dataReader.Read()
Session("User") = strUser
Session("SuperEmpID") = dataReader.GetString(1).ToString
Session("userName") = dataReader.GetString(2).ToString
Session("Role") = dataReader.GetString(3).ToString
Session("deptID") = dataReader.GetString(4).ToString
End While

dataReader.Close()

SqlCommand2.Parameters.Add(New SqlParameter("@dotnet.itags.org.deptID", Session("deptID")))
dataReader = SqlCommand2.ExecuteReader

While dataReader.Read
Session("companyID") = dataReader.GetString(1).ToString
Session("facilityID") = dataReader.GetString(2).ToString
Session("empID") = dataReader.GetString(4).ToString
Session("deptID") = dataReader.GetString(6).ToString
Session("Shift") = dataReader.GetString(8).ToString
End While

Response.Redirect("ReviewInterPersonal.aspx")
dataReader.Close()

'Closes Connection to DB
SqlConnection2.Close()
End Sub

much thanks,
jasonThe common method is to use Debug.Write to write out any messages you want. They'll show up in the output below when you run the application in the IDE.

The other thing I noticed is that you are using While loops. If you are only retrieving one row of data, you Simply use


DataReader.Read
Session("companyID) = dataReader.GetString(1).ToString

etc...

and then close it out like you are.

If you are retrieving multiple rows in your dataset, you need to be aware that each time you loop you are overwriting the prior values.

If you really need to store large amounts of data, you should consider using a DataSet with three datatable objects and then storing the DataSet in a Session Variable.