Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Thursday, March 29, 2012

Passing values from labels to text boxes via session variables

I'm passing label values from one page to text boxes in another page for user update. I'm using session variables, but I have been unable to display the passed values in the receiving text boxes. I'm not sure if the syntax is wrong or if the constructs are inappropriate. I'm new and need help.

<code>
SENDING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub doSubmit(Source as Object, E as EventArgs)
Context.Items.Add("first", txtFirst.text)
Context.Items.Add("last", txtLast.text)
Server.Transfer("3.aspx")
End Sub

</script>
<html
<head>
<title>1.aspx</title>
</head
<body
<form id="form1" runat="server">
First Name: <asp:TextBox id="txtFirst" runat="server" /><br>
Last Name: <asp:TextBox id="txtLast" runat="server" />
<asp:Button id="button1" Text="Submit" onclick="doSubmit" runat="server" />
</Form>
</body>
</html
RECEIVING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub Page_Load(Source as Object, E as EventArgs)

label1.text = "The Name you entered was : " & Context.Items("first") & " " & _
Context.Items("last")
textbox1.text = Context.Items("First")
textbox2.text = Context.Items("Last")

End Sub

</script>
<html>
<head>
<title>Second Page</title>
<asp:Label ID="label1" runat="server" />
</head>
<body>
<form name="Form1" runat="server">
<asp:TextBox id="textBox1" Text='<%# "textbox1" %>' runat="server"></asp:TextBox>
<asp:TextBox id="textBox2" Text='<%# "textbox2" %>' runat="server"></asp:TextBox>
</form>
</body>
</htmlIn the recieving pae's load event you're setting the value of the textbox so you don't need to bind the text box's value to itself (so just leave out the "Text=' etc." attribute).

Also, the items collection is case sensitive. You're adding items as "first" and "last" but you're trying to retrieve values from "First" and "Last". Choose a case and stick with it and the problem is resolved.
you made my day Chapel21. thanx for the prompt response and the explanation given, it makes a bit clearer what each line of code does.

sometimes I think I should've studied CGI scripting 5 years ago, when i had time to invest. by now, ASP .NET should've been simpler to understand and use, or may be not.. thanx again,

Saturday, March 24, 2012

Passing variables from datagrid to code-behind?

This is a bit embarassing, but I just can't seem to figure it out...
I have a simple datagrid that uses a calendar control to display information by a selected date. One field of the datagrid is a hyperlink column that allows the user to see additional details about each item in a pop-up window.
The pop-up window is another simple datagrid, using a code-behind to look-up the extra information.
The (Access) database uses separate tables for each month of the year (0105, 0205, etc.) and which table we need to read is determined by the selected month of the calendar control.
But I cannot figure out how to pass the month to the code behind to use the correct table in the query for detailed information.
Here is the primary datagrid hyperlink column:
<asp:HyperLinkColumn
DataTextField="Title"
DataNavigateUrlField="ResvNum"
DataNavigateUrlFormatString="javascript: var popWindow=window.open('event-detail.aspx?id={0}', 'popWindow'); popWindow.focus();"
Target="_self"
HeaderText="Title">
</asp:HyperLinkColumn>
[ResvNum is the primary key for each table, Access auto-increment]
And here is the code-behind (minus 'Import' statements):
public class Detail : Inherits System.Web.UI.Page
public eventDetail as DataGrid

private sub Page_Load (sender as object, e as System.EventArgs)
dim _id as String = Request.QueryString("id")
dim strSQL as String = "SELECT [0805].ResvNum, [0805].Dy, [0805].BegTime, [0805].Ending, [0805].EventType, [0805].Title, [0805].Person, Facility.BldgName, Facility.Abbrev " & _
"FROM Facility LEFT JOIN [0805] ON Facility.FacNum = [0805].Room " & _
"WHERE [0805].ResvNum = " & _id & ""
eventDetail.DataSource = getDetail(strSQL)
eventDetail.DataBind()
end sub

private function getDetail (strSQL as string) as oleDbDataReader
dim dtrDetail as oleDbDataReader
dim detailConn as oleDbConnection = new oleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath("../TESTDATA/TEST.mdb") & ";")
dim detailCmd as oleDbCommand = new oleDbCommand(strSQL, detailConn)
detailCmd.Connection.Open()
dtrDetail = detailCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
return dtrDetail
end function
end class
This is hard-coded to read the data table for August 2005. It is the [0805] I need to dynamically change depending on the selected date.
How do I pass that date to the code-behind query?
Thanks,
Tinker

You can only send 1 value if you use the datanavigatfield - but you canconstruct your own datanavigaturl and use template columns
<ItemTemplate>
<asp:HyperLink id="linkColumn1" runat="server"Text='<%# DataBinder.Eval(Container,"DataItem.MyDataField") %>'Target=_blank NavigateUrl='<%#"event-detail.aspx?id="& DataBinder.Eval(Container,"DataItem.MyDataField") & "?other_param=" & DataBinder.Eval(Container,"DataItem.MyOtherDataField") %>'>
</asp:HyperLink>
</ItemTemplate>
HTH

uncleb --
Thank you for this, and it makes sense -- but the file identifier is not a dataitem. It is derived from the calendar control as
qryFile = calDate.SelectedDate.ToString("MMyy")
and used in the query as
strSQL = "SELECT ResvNum, Person FROM qryFile"
So I can't pass it as part fo the dataitems collection.
Or -- at least -- I still don't know how to identifiy it to send it on to the code-behind.
If there's a refernce article, please send me off to read it.
Thanks again,


<ItemTemplate>
<asp:HyperLink id="linkColumn1" runat="server"Text='<%# DataBinder.Eval(Container,"DataItem.MyDataField") %>'Target=_blank NavigateUrl='<%#"event-detail.aspx?id="& DataBinder.Eval(Container,"DataItem.MyDataField") & "?qryFile=" &calDate.SelectedDate.ToString("MMyy") %>'>
</asp:HyperLink>
</ItemTemplate>
if the calendar is on the same page and loaded with the right date . Ifnot, I would use a button - then in the click event set the urlstringusing the datagrid datakeyfield and the calDate

HTH

YES! This works!
Thanks for hanging-in and guiding me through this. Appreciate it HUGELY.

Okay, I spoke too soon...
<asp:HyperLink id="linkColumn1" runat="server"
Text = '<%# DataBinder.Eval(Container,"DataItem.Title") %>'
NavigateUrl = '<%# "event-detail.aspx?qryFile = " & calDate.SelectedDate.ToString("MMyy") & "& ?id = "& DataBinder.Eval(Container, "DataItem.ResvNum") %>'
Target = _blank>
</asp:HyperLink>

Does not seem to be passing the second variable to the code behind, regardless of whether I rearrange the variable to make "id" first or second.
In the code-behind, I added:
trace.warn ("Incoming File " & Request.QueryString("qryFile "))
trace.warn ("Incoming ID " & Request.QueryString("id"))

dim _qryFile as String = Request.QueryString("qryFile ")
dim _id as String = Request.QueryString("id")

trace.warn ("Query File " & _qryFile)
trace.warn ("Query ID " & _id)
And these are the results of the trace.warnings:
Incoming File = 0805
Incoming ID =
Query File = 0805
Query ID =

(Reversing the order in which I pass the variables -- putting "id" first -- passes the ID, but not the qryFile date)
What am I doing wrong in the HyperLink NavigateUrl statement?


try..
NavigateUrl = '<%# "event-detail.aspx?qryFile=" &calDate.SelectedDate.ToString("MMyy") & "?id=" &DataBinder.Eval(Container, "DataItem.ResvNum") %>'
I took out an " &" and got rid of some spaces - no spaces in querystrings.



Well, you're still haniging in with me, and I appreciate it.
Didn't work. When I remove the '&' in the navurl, the variables are passed as a single variable, and the trace showsFileID = 0805?id=1769andResvNum=. I did remove all of the blank spaces, however.
I'm not sure what I'm seeing here, but maybe this will help: when the cursor is over the link on the (first page) data grid, the IE status bar shows that the link is
events-detail.aspx?qryFile=0805&?id=1120 -- which is a valid record id (ResvNum) in an existing table, and that LOOKS right to me. But the "id" is still not making it to the code-behind...
I'm kind of at a loss with this, and I'm just not smart enough to see what I'm doing wrong.
If there's anything more I can add to this thread that might help pinpoint my error, let me know?

Sorry , my fault

try..
NavigateUrl = '<%# "event-detail.aspx?qryFile=" &calDate.SelectedDate.ToString("MMyy") & "&id=" &DataBinder.Eval(Container, "DataItem.ResvNum") %>'
there is only one question mark in a querystring- params are seperated by "&"

So was it all just a test to see if I'd finally admit how dumb I am? 8-)
The two "?" was the problem; it is all working. I've been staring at it for three days and didn't see it.
Again, many thanks.

Wednesday, March 21, 2012

Passing varuiables to on form to another

I am having trouble passing variables from on form to another. .aspx. I am using a GridView to display the table. The user inputs the LastName they want to look up. Then I want to send that variable for LastName to another form site so they can edit those entities. Oh... all confused!

Try looking into the session object and viewstate.

This works... But

*Test.aspx*

Sub edit(ByVal SenderAsObject,ByVal EAs EventArgs)

Response.Redirect("Default.aspx?name=" & System.Web.HttpUtility.UrlEncode(LName.Text))

EndSub

*Default.aspx*

Sub Page_Load(ByVal SenderAsObject,ByVal EAs EventArgs)IfNot (Page.IsPostBack)Then

NameLabel.Text = Request.Params(

"LName")EndIfEndSub<formaction="default.aspx"runat="server">

Hi

<asp:labelid="NameLabel"runat="server"/>!

I can't get it to display. Its in the URL, but its not displaying. Then once i know i got the variable then i want to display a dataform. Thanks Nic


You should check out this webpage:http://blogs.wwwcoder.com/psantry/archive/2004/05/14/398.aspx

If that doesn't help you, maybe you could look into Request.Querystring instead of Request.Params.

Hope this helps.


Modify your code as following:

*Default.aspx*

If Not (Page.IsPostBack) Then

NameLabel.Text = Request.QueryString("name")

End If


I have written a small article relating to passing values between pages. Here is the URL:

Passing values between pages

Check if that helps

Friday, March 16, 2012

Password Answer

Hello,
How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.
Thanks,
MiguelOn Jun 26, 8:21 pm, shapper <mdmo...@.gmail.com> wrote:
> Hello,
> How can I get the Password Answer string on Asp.NET 2.0 Membership?
> I want to display it but I can't find the function to get it.
> Thanks,
> Miguel
hi...
so far i tried few times but didn't succeed
if (Page.User.Identity.IsAuthenticated)
{
System.Web.Security.MembershipUser user =
System.Web.Security.Membership.GetUser(Page.User.Identity.Name);
string question = user.PasswordQuestion;
}
using this i was able to get user info but not yet the answer in clear
text format...
then i look in to the ASPNETDB.MDF database in table aspnet_membership
table PasswordAnswer column keep the data ... but its encripted...
perhaps you can took a attempt to write your own fucntion to get the
answer...
Thanks
Masudur
http://munnacs.110mb.com
By default, you are dealing with one way hashes in Membership. Even if you
use AES instead, via config, you will have to deal with the constraints of
the system or write your own custom Membership Provider.
There are certain elements you can hit with configuration alone.
At present, I know of no way to pull the info you want from the standard
provider, due to security constraints. It can be reverse engineered, but the
object model is fairly deep.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
****************************************
********
Think outside the box!
****************************************
********
"shapper" <mdmoura@.gmail.com> wrote in message
news:1182867663.395933.115720@.u2g2000hsc.googlegroups.com...
> Hello,
> How can I get the Password Answer string on Asp.NET 2.0 Membership?
> I want to display it but I can't find the function to get it.
> Thanks,
> Miguel
>

Password Answer

Hello,

How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.

Thanks,
MiguelBy default, you are dealing with one way hashes in Membership. Even if you
use AES instead, via config, you will have to deal with the constraints of
the system or write your own custom Membership Provider.

There are certain elements you can hit with configuration alone.

At present, I know of no way to pull the info you want from the standard
provider, due to security constraints. It can be reverse engineered, but the
object model is fairly deep.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"shapper" <mdmoura@.gmail.comwrote in message
news:1182867663.395933.115720@.u2g2000hsc.googlegro ups.com...

Quote:

Originally Posted by

Hello,
>
How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.
>
Thanks,
Miguel
>