Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Referencing a LinkButton in javascript

Reply
Thread Tools

Referencing a LinkButton in javascript

 
 
DanG
Guest
Posts: n/a
 
      10-03-2006
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

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-03-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VpdGg=?=
Guest
Posts: n/a
 
      10-03-2006
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
>
>

 
Reply With Quote
 
DanG
Guest
Posts: n/a
 
      10-03-2006
I tried fld.getType(); "Object does not support this property or
method".

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing to LinkButton in Gridview TemplateField Peter ASP .Net 7 07-01-2009 03:36 PM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net 3 09-08-2005 09:41 AM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net Datagrid Control 1 09-08-2005 08:44 AM
User Control + <asp:LinkButton> = JavaScript Error Fresh Air Rider ASP .Net 0 03-02-2004 10:34 PM
Disabling LinkButton using JavaScript? Jeelz ASP .Net 2 06-28-2003 08:13 PM



Advertisments