Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hai,

I have a Button Named as ADD. when click that button Dialog will be open with Date of Birth and Contact no like that..

In Date of Birth field i need Datepicker. I used jquery datepicker and ajax calender extender. But Calender is not showing inside dialog. Without dialog box working fine.

How to get Datepicker inside dialog or Popupwindow.

Script for Opening Dialog:
C#
function openForm() {
                //
                dialog.show();
                dialog.setContent($("#formDiv"));
                dialog.moveTo(screen.width / 2 - 250, screen.height / 2 - 250);
}

VB
For Jquery calender
$(function () {
                    // Datepicker
                    $("#phGrid_txtDOB").datepicker();
                });



Plz help any one.

Thank you
Posted
Comments
F-ES Sitecore 19-Aug-15 6:02am    
javascript runs off the source sent to the browser, not your aspx\ascx files. View the source and see if there is an element with an id of "phGrid_txtDOB" as that is what you are attaching the datepicker too. You can either use the proper ID using the ClientID property of your server controls, or use the "contains" jQuery selector.

1 solution

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="App_Themes/Theme1/Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">


  • <asp:LinkButton ID="LinkButton_signup" runat="server" CssClass="nav4" Visible="true"
    OnClick="LinkButton_signup_Click" CausesValidation="false">Sign Up

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">

<asp:UpdatePanel ID="UpdatePanel2" runat="server" Visible="false">
<contenttemplate>
<asp:Label ID="lblsign_up" runat="server" Text="">
<asp:ModalPopupExtender ID="ModalPopupExtender_Sign_Up" runat="server" PopupControlID="Sign_Up"
TargetControlID="lblsign_up" CancelControlID="Sign_up_Close">

<div runat="server" id="Sign_Up" class="modalDialog">

X

Registration




Your Name
<asp:TextBox ID="txt_name" runat="server" CssClass="txt_medium" onkeypress="return isAlphabetKey(event)">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="txt_name" ForeColor="Red" ValidationGroup="Regitsration">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Enter Valid Name"
ControlToValidate="txt_name" ValidationExpression="\D{2,30}" ForeColor="Red"
ValidationGroup="Regitsration">
Address
<asp:TextBox ID="txt_address" runat="server" CssClass="txt_address" TextMode="MultiLine">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_address" ForeColor="Red">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Enter Valid Address"
ValidationGroup="Regitsration" ControlToValidate="txt_address" ValidationExpression="\D{5,100}"
ForeColor="Red">
Pincode
<asp:TextBox ID="txt_rpincode" runat="server" CssClass="txt" onKeyPress="return isNumberKey(event)">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_rpincode" ForeColor="Red">
<asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ErrorMessage="Enter Valid Pincode"
ValidationGroup="Regitsration" ControlToValidate="txt_rpincode" ValidationExpression="\d{6}"
ForeColor="Red">
Gender
<asp:RadioButton ID="RadioButton_M" runat="server" Checked="true" GroupName="gender" /><asp:Image
ID="Image1" runat="server" Height="20" Width="25" ImageUrl="~/Images/boy.png" />
<asp:RadioButton ID="RadioButton_F" runat="server" GroupName="gender" /><asp:Image
ID="Image2" runat="server" Height="20" Width="25" ImageUrl="~/Images/browser-girl-firefox-icon.png" />
Image
<asp:FileUpload ID="FU_user_img" runat="server" />
City
<asp:TextBox ID="txt_city" runat="server" CssClass="txt_medium">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_city" ForeColor="Red">
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Enter Valid City"
ValidationGroup="Regitsration" ControlToValidate="txt_city" ValidationExpression="\D{3,30}"
ForeColor="Red">
Mobile Number
<asp:TextBox ID="txt_contact" runat="server" CssClass="txt_medium">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_contact" ForeColor="Red">
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ErrorMessage="Enter Valid Name"
ValidationGroup="Regitsration" ControlToValidate="txt_contact" ValidationExpression="\d{10}"
ForeColor="Red">
E-mail
<asp:TextBox ID="txt_email" runat="server" CssClass="txt_medium">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_email" ForeColor="Red">
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ErrorMessage="Enter Valid Email"
ControlToValidate="txt_email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\D\D+)*"
ValidationGroup="Regitsration" ForeColor="Red">
Password
<asp:TextBox ID="txt_pass" runat="server" CssClass="txt_medium" TextMode="Password">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
ValidationGroup="Regitsration" ControlToValidate="txt_pass" ForeColor="Red">
Confirm Password
<asp:TextBox ID="txt_confirm_pass" runat="server" CssClass="txt_medium" TextMode="Password">
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Password not match"
ValidationGroup="Regitsration" ControlToCompare="txt_pass" ControlToValidate="txt_confirm_pass"
ForeColor="Red">
Caledar Extender <asp:TextBox ID="TextBox1" runat="server">
<asp:Button ID="btn_cal" runat="server" Text="Calender Extender" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd-MM-yyyy" PopupButtonID="btn_cal"
TargetControlID="TextBox1">

<asp:ImageButton ID="imgbtn_register" runat="server" ImageUrl="~/Images/register-now-button.png"
Height="50" Width="100" OnClick="imgbtn_register_Click" />





<triggers> <asp:PostBackTrigger ControlID="imgbtn_register" />


</form>
</body>
</html>


in the .cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void LinkButton_signup_Click(object sender, EventArgs e)
{
UpdatePanel2.Visible = true;
ModalPopupExtender_Sign_Up.Show();
}
protected void imgbtn_register_Click(object sender, ImageClickEventArgs e)
{

}
}
 
Share this answer
 
v2
Comments
Meer Wajeed Ali 19-Aug-15 7:58am    
Ajax calender extender also not working inside dialog box.
Rathod Prince 19-Aug-15 8:17am    
you have a ajax toolkit
Member 11570261 19-Aug-15 9:00am    
yes i have ajax tool kit. When ever i am using calender extender in dialogbox or popups on that time it's not working. Without using dialogbox calender extender working fine.
Rathod Prince 19-Aug-15 9:09am    
please post your email id if i find the solution i send you
Member 11570261 19-Aug-15 9:28am    
ok. Thanking you for replying.
My mail id is: jobalert888@gmail.com
I need how to add datetime picker for DOB textbox that is inside dialogbox or popupbox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900