473,748 Members | 4,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing a LinkButton in javascript

Hi

I used to have an ImageButton in my datagrid, and referenced the
control in the javascript with:
var fld = document.getEle mentById('datag rid__ctl2_btnEd it');
alert(fld); //returns "[object]" >Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getEle mentById('datag rid__ctl2_btnEd it'); //Same as
above
alert(fld); //returns "javascript :
__doPostBack('d atagrid$_ctl2$b tnEdit','');" >Bad

It's returning the javascript to execute, rather than the object
itself.

So how do I reference the LinkButton object???

TIA
Dan

Oct 3 '06 #1
3 2121
You should not hard code .NET controls in JavaScript. You should assemble
the JavaScript in the code behind and reference the name of the control
there so you can switch controls without a lot of pain.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************** *************** *************** ****
Think outside of the box!
*************** *************** *************** ****
"DanG" <da**@rmci.netw rote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Hi

I used to have an ImageButton in my datagrid, and referenced the
control in the javascript with:
var fld = document.getEle mentById('datag rid__ctl2_btnEd it');
alert(fld); //returns "[object]" >Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getEle mentById('datag rid__ctl2_btnEd it'); //Same as
above
alert(fld); //returns "javascript :
__doPostBack('d atagrid$_ctl2$b tnEdit','');" >Bad

It's returning the javascript to execute, rather than the object
itself.

So how do I reference the LinkButton object???

TIA
Dan

Oct 3 '06 #2
Check the value of fld.getType();

-Keith

"DanG" wrote:
Hi

I used to have an ImageButton in my datagrid, and referenced the
control in the javascript with:
var fld = document.getEle mentById('datag rid__ctl2_btnEd it');
alert(fld); //returns "[object]" >Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getEle mentById('datag rid__ctl2_btnEd it'); //Same as
above
alert(fld); //returns "javascript :
__doPostBack('d atagrid$_ctl2$b tnEdit','');" >Bad

It's returning the javascript to execute, rather than the object
itself.

So how do I reference the LinkButton object???

TIA
Dan

Oct 3 '06 #3
I tried fld.getType(); "Object does not support this property or
method".

Oct 3 '06 #4

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

Similar topics

5
3748
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the following code fragments in which I want to list through all files on a directory with a link to download each file by passing a filename and whether or not to force the download dialog box to appear.
1
5326
by: Nevyn Twyll | last post by:
I have a DataList; in the DataList's , I have a LinkButton and a few listboxes. When the LinkButton is pressed, I need to get the ID of the selected item in one of the Listbox controls. Then I want to launch another web page in a seperate window, using that ID. In the header of the web page, I have a javascript function LaunchMyWindow(iID) that launches that window. For a normal LinkButton Control, I could just use
6
9072
by: Al Cohen | last post by:
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed. I'd like to disable my LinkButton during this period to prevent multiple submissions. (Obviously) the disabling should be done at the client side to prevent any delay. I've tried adding some javascript to LinkButton.Attributes: LinkButton1.Attributes.Add("onclick",...
2
5595
by: Dave | last post by:
Hi, I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes a few seconds. The js function simply sets the css style to display. <asp:TemplateColumn> <ItemTemplate> <asp:LinkButton Runat="server" CommandName="Select" ID="lbtnCompanyName"> <%# DataBinder.Eval(Container.DataItem, "CompanyName")%>...
6
4254
by: Shivakumar | last post by:
Hi all, Recently i have updated my vs.net 2003 project to vs.net 2005 and i have successfully converted my code and found no problem with all my controls except the one which is the linkbutton. I have added the linkbutton control in my datagrid and it rendered perfectly but whenever i clicked the linkbutton am getting this error 'event' is null or not an object.
0
1266
by: Oscar Thornell | last post by:
Hi, Problem: LinkButton control does not POST Environment: Win 20003, ASP.NET 2.0, XHTML Target/device: Symbian v.9/Opera 8.60 (168) based smartphones I am developing a mobile web application (VS.NET 2005/xhtml) the target device(s) are Symbian (v.9) based smartphones. We recently recived a new "batch" of test devices with upgraded software..
3
2772
by: Learner | last post by:
Hello, I have two buttons on one of my VehicleDetails.aspx page. Obiviously these two buttons takes the user to two different pages. Now my client is interested in having a linkbutton instead of the two buttons. Once the user clicks on the linkbutton a javascript dialog box popsup that says "Is the Lessee buying this vehicle?" and with two buttons "Yes" and "No". If user clicks "yes" it should go to DealerQuestions.aspx" and if "No" it...
3
7021
by: John | last post by:
Hi I have been trying to change the css class of a linkbutton without succes ( I dont want to change the cssclass property). Maybe somebody knowshow to do this?? th.John <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
3323
by: RN1 | last post by:
An ASPX page, named LinkButton.aspx, has a single LinkButton & nothing else. The code is very simple: <form runat="server"> <asp:LinkButton ID="lnk" PostBackUrl="Page1.aspx" Text="CLICK" runat="server"/> </form> When I run the above code in my local; (Intranet) IIS server, then when the LinkButton is clicked, the user is taken to Page1.aspx but
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.