Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
How to suggest available username
Play lesson

jQuery tutorial for beginners - How to suggest available username

5.0 (2)
25 learners

What you'll learn

This course includes

  • 22.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

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/06/how-to-suggest-available-username.html Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1 In this video we will discuss, how to suggest available username using asp.net web services and jquery ajax. This is continuation to Part 65, please watch Part 65 before proceeding. When you try to create a gmail account, if the username that you have provided is already taken by another user, you will be suggested with a username that is available. Once you click on the available username, the username textbox will be populated with the suggested username.g Let us now discuss how to achieve this using asp.net web services and jQuery AJAX. Step 1 : Modify RegistrationService.asmx.cs as shown below. using System; 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 RegistrationService : System.Web.Services.WebService { public bool UserNameExists(string userName) { string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("spUserNameExists", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@UserName", Value = userName }); con.Open(); return Convert.ToBoolean(cmd.ExecuteScalar()); } } [WebMethod] public void GetAvailableUserName(string userName) { Registration regsitration = new Registration(); regsitration.UserNameInUse = false; while(UserNameExists(userName)) { Random random = new Random(); int randomNumber = random.Next(1, 100); userName = userName + randomNumber.ToString(); regsitration.UserNameInUse = true; } regsitration.UserName = userName; JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(regsitration)); } } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere