473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Javascript hyperlink ID in a Datalist = Undefined

I have an ASPX page with a DataList. The ListItems contain a
DropDownList and a Hyper Link. The user selects an Item from the
Dropdown box and then selects the hyperlink to edit that item.

My thought was to grab the ID, ClientID, or UniqueID of the Hyperlink
and then build the name of the DropDownList to grab the value to pass.
The problem is that the value keeps coming back Undefined. How can I
get the dynamic name created at runtime?

My Code:

**javascript**
function floorplanpopup(i)
{
var j = i.ClientId.length - 33;
var no = i.ClientId.substring(20, j);
var x =
document.getElementById("dl_notification:_ctl"+no+ ":dd_floorplan");
day = new Date();
id = day.getTime();
eval("page"+id + " =
window.open('FloorPlanSetup.aspx?did="+x.value+"', '" + id + "',
'width=350, height=500');");
}

**Datalist Code**
<asp:label class="lblnormal" id="lbl_floorplan" runat="server"
Font-Size="X-Small">Floor Plan Name:</asp:label>

<asp:dropdownlist class="normal" id="dd_floorplan" runat="server"
DataTextField="FLOORPLAN_NAME"
DataValueField="FLOORPLAN_ID"></asp:dropdownlist>

<asp:HyperLink id="hl_floorplan" runat="server"
NavigateUrl="javascript:floorplanpopup(this);"
ImageUrl="images/AddButton.gif"></asp:HyperLink>
Anyhelp is greatly appreciated.

~Brad

Apr 25 '06 #1
2 2268
you want the uniqueid or calc dropdown id from passed.

function floorplanpopup(i)
{
var x =
document.getElementById(i.id.replace(/hl_floorplan/i,'dl_floorplan'));
.....

-- bruce (sqlwork.com)
<mi******@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
I have an ASPX page with a DataList. The ListItems contain a
DropDownList and a Hyper Link. The user selects an Item from the
Dropdown box and then selects the hyperlink to edit that item.

My thought was to grab the ID, ClientID, or UniqueID of the Hyperlink
and then build the name of the DropDownList to grab the value to pass.
The problem is that the value keeps coming back Undefined. How can I
get the dynamic name created at runtime?

My Code:

**javascript**
function floorplanpopup(i)
{
var j = i.ClientId.length - 33;
var no = i.ClientId.substring(20, j);
var x =
document.getElementById("dl_notification:_ctl"+no+ ":dd_floorplan");
day = new Date();
id = day.getTime();
eval("page"+id + " =
window.open('FloorPlanSetup.aspx?did="+x.value+"', '" + id + "',
'width=350, height=500');");
}

**Datalist Code**
<asp:label class="lblnormal" id="lbl_floorplan" runat="server"
Font-Size="X-Small">Floor Plan Name:</asp:label>

<asp:dropdownlist class="normal" id="dd_floorplan" runat="server"
DataTextField="FLOORPLAN_NAME"
DataValueField="FLOORPLAN_ID"></asp:dropdownlist>

<asp:HyperLink id="hl_floorplan" runat="server"
NavigateUrl="javascript:floorplanpopup(this);"
ImageUrl="images/AddButton.gif"></asp:HyperLink>
Anyhelp is greatly appreciated.

~Brad

Apr 25 '06 #2
That really helps out in the changing of the name, but I still have the
issue that the i.id is undefined.

If I use the code you suggest, it comes back with an error: 'id' is
null or not an object.

Is it possible to pull the ID from a hyperlink?

Apr 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arjen | last post by:
Hello, Here is my datalist. <asp:DataList id="myDataList" CellPadding="4" Width="100%" runat="server"> <ItemTemplate> <span class="Normal"> <asp:HyperLink id="link" Text='<%#...
0
by: Dave | last post by:
Hi , I have the following where I need to append a string variable inside a hyperlink template, inside a datalist. The variable 'categoryList' is the culprit. No matter where this variable is...
2
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of...
9
by: Leon | last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks. <asp:datalist id="DataList1" runat="server" RepeatColumns="4"> <ItemTemplate> <asp:HyperLink id=HyperLink1 ImageUrl=...
12
by: Joe | last post by:
Hello All: I'm sure that one of you can quickly spot the error in my script. I am using a small javascript function to retrieve the text of a hyperlink in a datagrid column. Here is my...
1
by: Elmo Watson | last post by:
Ok - I've got a datalist - in the template, there is a hyperlink, in which, I need to dynamically use the record's ID inside a Javascript function (a popup window function, which works perfectly...
0
by: vidhuraj | last post by:
hi all i have a hyperlink control and image control in my datalist i have binded the values for it ie, datalist will now display some images in image control and their corresponding ID in the...
1
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub Page_Load(obj As Object, ea As EventArgs) Dim sqlReader As SqlDataReader sqlReader = 'calling a function that returns SqlDataReader ...
7
by: Peter | last post by:
I have a HoverMenuExtender which contains an asp:PlaceHolder, this place holder has a User Control and this control contrains a Button. The problem I am having is after the button fires the click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.