[thelist] URL variable to FORM input field variable problem
Bruso, John
jbruso at SHERIDAN.EDU
Fri Feb 24 11:11:07 CST 2006
I thought I had this working at some point, and now it's not and I'm not
sure why. I have a URL with a variable, and I want that variable to
populate a field in a form on the page the URL is pointing to.
So... in the link
https://www.sheridan.edu/uportal/login/index.htm?uPfname=eservices-outlo
ok, uPfname=eservices-outlook needs to write to a hidden field in a
form.
My full code is at the link above. Here's the relevant lines I'm having
problems with. The javascript alert I'm getting is "object object".
<head>
Code:
<SCRIPT src="index_files/link-parser.js" type=text/javascript> </SCRIPT>
<SCRIPT>
var args = parseQueryString ();
var myValue = args["uP_fname"];
alert (args);
</SCRIPT>
</head>
<body>
<form>
Code:
<script>
document.write("<input type='hidden' name='uP_fname'
value='"+myValue+"'>");
</script>
</form>
index_files/link-parser.js
Code:
function parseQueryString (str)
{
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query)
{
var fields = query.split('&');
for (var f = 0; f < fields.length; f++)
{
var field = fields[f].split('=');
args[unescape(field[0].replace(/\+/g, ' '))] =
unescape(field[1].replace(/\+/g, ' '));
}
}
return args;
}
-------------------------
John Bruso
IS Developer
Sheridan College
ph 307.674-6446-2608
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tab Alleman
Sent: Tuesday, February 21, 2006 9:57 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] (asp.net) accessing controls created at runtime.
So you're saying I should DIM the control in page_init, but where do I
"FindControl()" it? Still in page_init, or in the submit_click event
handler?
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of James Conley
> Sent: Tuesday, February 21, 2006 11:46 AM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] (asp.net) accessing controls created
> at runtime.
>
>
> If you want to get events from dynamically created controls then you
> need to dynamically create those controls on post back
> *before* the post
> back data is "restored" into the controls.
>
> So - any controls you create dynamically should be done in either
> page_init or page_load. Probably page_init is safer.
>
>
> james c
>
>
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tab Alleman
> Sent: Tuesday, February 21, 2006 11:26 AM
> To: Evolt Thelist (E-mail)
> Subject: [thelist] (asp.net) accessing controls created at runtime.
>
> I am creating controls at runtime, and they show up on the page, but
> when the page is submitted, I can't find them. What am I doing wrong?
>
> To reduce the code to critical elements, I have a datacell on my .aspx
> page like this:
>
> <td class='TableData' id="tdAttorney" runat="server" nowrap></td>
>
>
> Then in my vb.net code-behind, I populate the cell like this:
>
> Dim tdAttorney As System.Web.UI.HtmlControls.HtmlTableCell
> tdAttorney = e.Item.FindControl("tdAttorney")
>
> 'add textboxes
> Dim tbAttorneyFirstName As New
> System.Web.UI.HtmlControls.HtmlInputText
> Dim tbAttorneyLastName As New System.Web.UI.HtmlControls.HtmlInputText
> With tbAttorneyFirstName
> .Value = e.Item.DataItem("AttorneyFirstName").ToString
> .Size = 20
> .ID = "tbAttorneyFirstName"
> .MaxLength = 50
> End With
> With tbAttorneyLastName
> .Value = e.Item.DataItem("AttorneyLastName").ToString
> .Size = 20
> .ID = "tbAttorneyLastName"
> .MaxLength = 50
> End With
>
> With tdAttorney
> .Controls.Add(tbAttorneyFirstName)
> .Controls.Add(tbAttorneyLastName)
> End With
>
> -----------
>
> Ok, all of this works...the textboxes show up on the page. In the
> submit_click handler, I've got this:
>
> tdAttorney = itemSI.FindControl("tdAttorney")
>
> tbAttorneyFirstName =
> tdAttorney.FindControl("tbAttorneyFirstName")
> tbAttorneyLastName =
> tdAttorney.FindControl("tbAttorneyLastName")
>
>
> ----when I stop the page in the debugger, it's finding tdAttorney (the
> datacell), but it's saying it doesn't contain any controls. The page
> doesn't contain the controls, either.
>
> What am I missing?
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester and
> archives of thelist go to: http://lists.evolt.org Workers of the Web,
> evolt !
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list