Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

javascript title property for tooltip


In a javascript function I am trying to set a tooltip, via the title attribute (see below)

  var fzip = document.getElementById('txtforeign');
  fzip.title = 'Foreign'

the txtforeign textbox is defined in my aspx as the following:
<asp:textbox ID="txtforeign" style="Z-INDEX: 139; LEFT: 502px; POSITION: absolute; TOP: 97px" MaxLength="10" Width="75" Visible="true" runat="server"></asp:TextBox>

my problem is in the codebehind in vb.net on a btnsubmit click event, I want to try to access the tooltip property for the textbox txtforeign that I just set in javascript but it is coming back a "" in the codebehind even though it will show 'Foreign' on the mouseover when I have the page up and I can't figure out for the life of me what I am doing wrong here.


  • 2
1 Solution
ZvonkoSystems architectCommented:
CodeBehind on Server does not see what the browser script has done.
The new set attributes are only present in browser and NOT on server side.

UFCWITAuthor Commented:
Thanks Zvonko,

Is there anyway properties that I can share between client and server, I need to be able to access a property that I can set between client and server to determine something on the button submit.

save the title in a hidden field :

<asp:Hidden ID="txtforeign_tooltip_value" runat="server"></asp:Hidden>

var fzip = document.getElementById('txtforeign');
fzip.title = 'Foreign';
document.getElement("<%= txtforeign_tooltip_value.ClientID %>").value = 'Foreign';
ZvonkoSystems architectCommented:
The answer is: No, you cannot send attributes on Submit.
You can only send form field values, URL parameters and Cookies to server.
The best choice is always to send the required attributes in form fields as in upper example.
You can do the hidden field store at attribute set time or at on form submit time you can refresh the hidden fields with current attribute values.
For example if you want to store the window scroll position then you have to fetch and send it somehow to server to adjust it again at next page display time.


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now