Change Thickbox Title in runtime

The Quest.

You want to change the thickbox title, runtime or thought the ASP vb/c# code.


The thickbox title is stored inside a div ID TB_ajaxWindowTitle


Simply use Jquery to get your way to this DIV and change the value to the one you want:

   1: $("#TB_ajaxWindowTitle").val("New Title")

I request you to use jquery, because if you’re using thickbox, this means you already have jquery included in your page.

But if you do not want to use jquery, do this:

   1: window.document.getElementById("TB_ajaxWindowTitle").innerHTML = "New Title"

Doing that in Runtime with ASP.NET

Ok, first ask yourself “why” would you do that?. I Recommend you always (when possible) keep all your client code in the cient side, but if you have found a good reason, then, simply call the RegisterClientScriptBlock.

   1: ClientScript.RegisterClientScriptBlock(Me.GetType(), "scriptKey", "$("#TB_ajaxWindowTitle").val("New Title")", True)

This will work if you are in a ASPX page (inheriting directly or indirectly from System.Web.UI.Page).

If you are inside a component, call Me.ClientScript.Page.RegisterClientScriptBlock.

And yes, use Me.Page.getType() to fill the first parameter.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: