LinkButton - bind field to ToolTip or CSSClass

I have a legacy asp.net 3.5 application. I need to bind a filed to CssClass so that i can utilize it via jquery.

Basically, in the datagrid, there are 2 buttons. Button one is visible and button two is not visible. On click of button one, i want to perform action and then make button two visible and hide button one. How can i do this? I just need a kick in the right direction…


[COLOR=blue]<[/COLOR][COLOR=maroon]asp[/COLOR][COLOR=blue]:[/COLOR][COLOR=maroon]LinkButton[/COLOR] [COLOR=red]ID[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"lnkDelete"[/COLOR] [COLOR=red]runat[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"server"[/COLOR]                                                   [COLOR=red]ToolTip[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"Delete Order [/COLOR]<%[COLOR=blue]#[/COLOR] DataBinder.Eval(Container.DataItem, "TransID")%>[COLOR=blue]"[/COLOR]                                                  [COLOR=red]OnClientClick[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"return DeleteOrder();"[/COLOR]                                                  [COLOR=red]OnClick[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"OrderDelete"[/COLOR] [COLOR=red]CommandArgument[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]'[/COLOR]<%[COLOR=blue]#[/COLOR] Eval("TransID") %>[COLOR=blue]'[/COLOR]                                                  [COLOR=red]CssClass[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]""[/COLOR][COLOR=blue]>[/COLOR]                                                 [COLOR=blue]<[/COLOR][COLOR=maroon]asp[/COLOR][COLOR=blue]:[/COLOR][COLOR=maroon]Image[/COLOR] [COLOR=red]ID[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"Image1"[/COLOR] [COLOR=red]runat[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"server"[/COLOR] [COLOR=red]ImageUrl[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"~/images/icons/delete.gif"[/COLOR] [COLOR=red]BorderStyle[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]"None"[/COLOR] [COLOR=blue]/>[/COLOR]                                                     [COLOR=blue]</[/COLOR][COLOR=maroon]asp[/COLOR][COLOR=blue]:[/COLOR][COLOR=maroon]LinkButton[/COLOR][COLOR=blue]>[/COLOR]

My current binding inside the tooltip results in an error, “the server tag is not well formed”.

ToolTip=“Delete Order <%# DataBinder.Eval(Container.DataItem, “TransID”)%>”

Should be

ToolTip=‘Delete Order <%# DataBinder.Eval(Container.DataItem, “TransID”)%>’

Thanks.

I finally got the chance to test this out and basically these don’t work:


[COLOR=red]ToolTip[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]'Delete Order [/COLOR]<%[COLOR=blue]#[/COLOR] Eval("TransID") %>[COLOR=blue] Response Type [/COLOR]<%[COLOR=blue]#[/COLOR] Eval("RespType") %>[COLOR=blue] Survey Code [/COLOR]<%[COLOR=blue]#[/COLOR] Eval("SurveyCode") %>[COLOR=blue]'[/COLOR] 
or[COLOR=red]
ToolTip[/COLOR][COLOR=blue]=[/COLOR][COLOR=blue]'[/COLOR]<%[COLOR=blue]#[/COLOR] String.Format("Delete Order [COLOR=mediumseagreen]{0}[/COLOR] Response Type [COLOR=mediumseagreen]{1}[/COLOR] Survey code [COLOR=mediumseagreen]{2}[/COLOR]",                                             
DataBinder.Eval([COLOR=red]Container[/COLOR].DataItem, "TransID"),                                                  
DataBinder.Eval([COLOR=red]Container[/COLOR].DataItem, "RespType"),                                                  
DataBinder.Eval([COLOR=red]Container[/COLOR].DataItem, "SurveyCode")%>[COLOR=blue])'[/COLOR]

Both above results in:


title="<%# String.Format(&quot;Delete Order {0} Response Type {1} Survey code {2}&quot; DataBinder.Eval(Container.DataItem, &quot;TransID&quot;), DataBinder.Eval(Container.DataItem, &quot;RespType&quot;), DataBinder.Eval(Container.DataItem, &quot;SurveyCode&quot;)%>)" 



Wow an asp.net 3.5 application is legacy now :slight_smile: Anyway there is a certain irony in seeing a link button being used which produces god awful obtrusive javascript alongside jquery which allows us to use elegant unobtrusive javascript but anyway I’m wandering.

I would recommend that when doing these complex databinding things to do it in your code behind. In the itemdatabound event grab a reference to your object, the linkbutton and set it’s values.attributes as necessary.

For the record these days I would only use a repeater (which gives me complete control over the table output so I can use proper table attributes for accessibility etc.) and standard controls like a hyperlink which will point to a page where my edit/delete operation will be confirmed or whatever else I need. Then when this works I’ll layer some jquery over my repeater to allow deletes/edits in place and so on but at all times if I remove the script or the user has script off it will still work.

Your point well taken…

I am fixing some ones else mess + i have a strict time line. Can’t change a whole lot other than fix and change as needed.

Legacy = 2.0 app which some one migrated to 3.5 but still is a whole lot 2.0.

Ah yeah I wasn’t blaming anyone. I look at horrible code everyday and it was all written by me over the last 10 years :slight_smile: Nobody else to blame. Anyway I was serious about doing this in itemdatabound. You don’t need to worry about single quotes and double quote in attributes and so on. Forgot to mention though I would use cssclass not tooltip as users hovering over the linkbutton will see the tooltip.

I really appreciate yur help and i was pointing to this:

I would recommend that when doing these complex databinding things to do it in your code behind. In the itemdatabound event grab a reference to your object, the linkbutton and set it’s values.attributes as necessary.

I have moved from classic asp to MVC. Don’t have much experience with asp.net and specially its controls. I am going to implement your advice during phase II where i may be able to change it to repeater.

Again, thanks for pointing me in the right direction. :slight_smile: