HomeОбразованиеRelated VideosMore From: kudvenkat

jquery tooltip from database

69 ratings | 16343 views
Link for all dot net and sql server video tutorial playlists https://www.youtube.com/user/kudvenkat/playlists?sort=dd&view=1 Link for slides, code samples and text version of the video http://csharp-video-tutorials.blogspot.com/2015/07/jquery-tooltip-from-database.html In this video, we will discuss how to retrieve tooltip text from database and display using jquery tooltip widget. The tooltip text should be retrieved from the database using ajax and display it using jquery tooltip widget Stored procedure to retrieve tooltip text by fieldname Create proc spGetTooltip @FieldName nvarchar(50) as Begin Select * from tblTooltip where FieldName = @FieldName End WebService using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web.Script.Serialization; using System.Web.Services; namespace Demo { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class TooltipService : System.Web.Services.WebService { [WebMethod] public void GetTooltip(string fieldName) { string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; Tooltip tooltip = new Tooltip(); using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("spGetTooltip", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(); parameter.ParameterName = "@FieldName"; parameter.Value = fieldName; cmd.Parameters.Add(parameter); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { tooltip.FieldName = rdr["FieldName"].ToString(); tooltip.TooltipText = rdr["TooltipText"].ToString(); } } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(tooltip)); } } } jQuery code $(document).ready(function () { $('.displayTooltip').tooltip({ content: getTooltip }); function getTooltip() { var returnValue = ''; $.ajax({ url: 'TooltipService.asmx/GetTooltip', method: 'post', data: { fieldName: $(this).attr('id') }, dataType: 'json', async: false, success: function (data) { returnValue = data.TooltipText; } }); return returnValue; } }); HTML <table> <tr> <td>First Name</td> <td> <input id="firstName" class="displayTooltip" title="" type="text" /> </td> </tr> <tr> <td>Last Name</td> <td> <input id="lastName" class="displayTooltip" title="" type="text" /> </td> </tr> <tr> <td>Department</td> <td> <input id="department" class="displayTooltip" title="" type="text" /> </td> </tr> </table>
Html code for embedding videos on your blog
Text Comments (9)
bra scene (2 years ago)
Priceless.. Thank you so much, all lessons from your tutorials are helping me with improving on .net coding !
Black n White (2 years ago)
This is helping cement in my mind how the back-end and front-end interact, thanks for this insight.
kudvenkat (2 years ago)
Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful. I have organised all the Dot Net & SQL Server videos in to playlists, which could be useful to you https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd If you need DVDs or to download all the videos for offline viewing please visit http://www.pragimtech.com/kudvenkat_dvd.aspx Slides and Text Version of the videos can be found on my blog http://csharp-video-tutorials.blogspot.com Tips to effectively use my youtube channel. https://www.youtube.com/watch?v=y780MwhY70s If you want to receive email alerts, when new videos are uploaded, please subscribe to my youtube channel. http://www.youtube.com/subscription_center?add_user=kudvenkat If you like these videos, please click on the THUMBS UP button below the video. May I ask you for a favor. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them.
Badre ARRAS (3 years ago)
i get this error : Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's
developernader (3 years ago)
Thank you Eng Venkat
developernader (3 years ago)
Thanks Eng Venkat
Tan YEW MENG (3 years ago)
Superb video on how to retrieve tooltip text from database and display using jquery tooltip widget.
Артем А (3 years ago)
cool
Mariusz Zaleski (3 years ago)
Awesome way of lecturing. I like to watch your videos. One Love :-)

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.