Go Premium for a chance to win a PS4. Enter to Win


javascript title property for tooltip

Posted on 2011-09-12
Medium Priority
Last Modified: 2012-05-12

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.


Question by:UFCWIT
  • 2
LVL 63

Expert Comment

ID: 36523556
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.


Author Comment

ID: 36523595
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.

LVL 82

Expert Comment

ID: 36523610
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';
LVL 63

Accepted Solution

Zvonko earned 2000 total points
ID: 36523680
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question