473,386 Members | 1,810 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,386 software developers and data experts.

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.getElementById('datagrid__ctl2_btnEdit');
alert(fld); //returns "[object]" >Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
above
alert(fld); //returns "javascript:
__doPostBack('datagrid$_ctl2$btnEdit','');" >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 2103
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.netwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Hi

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

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
above
alert(fld); //returns "javascript:
__doPostBack('datagrid$_ctl2$btnEdit','');" >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.getElementById('datagrid__ctl2_btnEdit');
alert(fld); //returns "[object]" >Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
above
alert(fld); //returns "javascript:
__doPostBack('datagrid$_ctl2$btnEdit','');" >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
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...
1
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...
6
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...
2
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...
6
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. ...
0
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...
3
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...
3
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...
4
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"...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.