protected void btnAddurl_Click(object sender, EventArgs e) { try { string url = txtvideoUrl.Text; if (txtvideoUrl.Text.Length > 0 && url.Contains("youtube.com")) { string videotitle = txtVideotitle.Text.Trim(); string ytFormattedUrl = GetYouTubeID(url); string shorturlid = GetShortID(ytFormattedUrl); string videodate = System.DateTime.Now.ToString(); videodate = Convert.ToDateTime(videodate).ToString("yyyy-MM-dd HH:mm:ss"); if (!CheckDuplicate(ytFormattedUrl)) { local_video.AddVideoUrl(videotitle, ytFormattedUrl, shorturlid, videodate); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Video Url Added Successfully!"; txtVideotitle.Text = ""; txtvideoUrl.Text = ""; BindgvVideos(); } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "This video already exist!"; } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "URL is not a valid YOUTUBE video link?"; } } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = ex.Message; } }