Click here to Skip to main content
16,020,633 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi everybody
i have astrange problem with my register page i have a clander which works fine but after i add acode to check user and email if available or not in database its impossble to work only work when i make refresh to the page or start with datetime clander before write the username or email
even loading gif doesnt work
this is my code

C#
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="register.ascx.cs" Inherits="UserControl_register"  %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>


<script src="Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.dynDateTime.min.js" type="text/javascript"></script>
<script src="Scripts/calendar-en.min.js" type="text/javascript"></script>
<link href="Styles/calendar-blue.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#<%=Txtbirthday.ClientID %>").dynDateTime({
            showsTime: true,
            ifFormat: "%Y/%m/%d %H:%M",
            daFormat: "%l;%M %p, %e %m, %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
            button: ".next()"
        });
    });
</script>

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

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

         <div class="container">
    <section class="register">
      <h1>
          Register on my site</h1>

        <div class="reg_section personal_info">
            <asp:Label ID="lbl_msg" runat="server" Text=""></asp:Label>
       </div>

      <div class="reg_section personal_info">
      <h3>Your Personal Information</h3>
       <asp:TextBox ID="Txtusername" placeholder="Your Desired Username" runat="server" OnTextChanged="Txtusername_TextChanged" AutoPostBack="true"></asp:TextBox>
         &nbsp;&nbsp;&nbsp;  <asp:Image ID="ImgUser" runat="server" />
         <h3>Your E_mail</h3>
       <asp:TextBox ID="Txtemail" placeholder="Your E-mail Address"  runat="server" OnTextChanged="Txtemail_TextChanged" AutoPostBack="true"></asp:TextBox>
        &nbsp;&nbsp;&nbsp;  <asp:Image ID="Imgemail" runat="server" />

       </div>

      <div class="reg_section password">
      <h3>Your Password</h3>
          <asp:TextBox ID="Txtpassword"  placeholder="Your Password" runat="server" TextMode="Password"></asp:TextBox>
          <asp:TextBox ID="Txtconfrimpass" placeholder="Confirm Password"  runat="server" TextMode="Password"></asp:TextBox>
          <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="Txtpassword" ControlToValidate="Txtconfrimpass" Display="Dynamic" ErrorMessage="password not match" ForeColor="#CC0000"></asp:CompareValidator>
      </div>

      <div class="reg_section password">
      <h3>Your Address</h3>
          <asp:DropDownList ID="ddlcountry" runat="server">
              <asp:ListItem Selected="True">Country</asp:ListItem>
              <asp:ListItem Value="C1">Egypt</asp:ListItem>
              <asp:ListItem Value="C2">Iraq</asp:ListItem>
              <asp:ListItem Value="C3">Palastine</asp:ListItem>
              <asp:ListItem Value="C4">Italy</asp:ListItem>
          </asp:DropDownList>

       <asp:TextBox ID="Txtaddress" placeholder="Your address" runat="server"></asp:TextBox>

          <h3>Phone</h3>
        <asp:TextBox ID="Txtphone" placeholder="phone 011-1234567" runat="server"></asp:TextBox>

        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="invaild phone" ControlToValidate="Txtphone" ForeColor="#CC0000" ValidationExpression="(\(\d{3}\)|\d{3}-)?\d{8}"></asp:RegularExpressionValidator>

      <div class="reg_section password">

      <h3>Birthday</h3>
        <asp:TextBox ID="Txtbirthday" placeholder="Birthday date" runat="server" ReadOnly="True"></asp:TextBox>
     &nbsp; <asp:Image ID="Imgclander" runat="server" ImageUrl="~/img/calender.png"></asp:Image>


      <h3>Gender</h3>

          <asp:DropDownList ID="ddlgender" runat="server">
              <asp:ListItem Selected="True">Gender</asp:ListItem>
              <asp:ListItem Value="M">Male</asp:ListItem>
              <asp:ListItem Value="F">Female</asp:ListItem>
            </asp:DropDownList>

           </div>

          <div class="reg_section password">
      <h3>Security Question</h3>

          <asp:DropDownList ID="ddlsecurityQuestion" runat="server">
              <asp:ListItem Selected="True" Value="Q1">Whats your fathers name ?</asp:ListItem>
              <asp:ListItem Value="Q2">Whats your best book ?</asp:ListItem>
              <asp:ListItem Value="Q3">Whats your best meal ?</asp:ListItem>
              <asp:ListItem Value="Q4">Whats your best fruit ?</asp:ListItem>
              <asp:ListItem Value="Q5">Whats your best channel ?</asp:ListItem>
            </asp:DropDownList>

               <asp:TextBox ID="Txtanswer" placeholder="Your answer" runat="server"></asp:TextBox>

           </div>

<div class="reg_section password">
          <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
                <asp:Image ID="Image1" runat="server" ImageUrl="~/img/loading.gif" />
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>

      </div>
      <p class="terms">
        <label>
            <asp:CheckBox ID="chbaccept" runat="server" />
            I accept  <a href="#">OAAM</a>Terms & Condition
        </label>
      </p>
             &nbsp;&nbsp;&nbsp;

             <asp:Button  ID="btnregister" runat="server" Text="Sign Up" BackColor="#AE6CAC" OnClick="btnregister_Click" BorderStyle="None"/>
    </section>
  </div>


</ContentTemplate>

</asp:UpdatePanel>



  <section class="about">
    This site is powered ##<a href="#">O>


the code behind


C#
public partial class UserControl_register : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void btnregister_Click(object sender, EventArgs e)
    {

        if (chbaccept !=null && chbaccept.Checked)  // to check  if he accept the terms or not
        {
            Member m = new Member();
            lbl_msg.Text = m.Register(Txtusername.Text, Txtemail.Text, Txtpassword.Text, ddlcountry.SelectedValue, Txtaddress.Text, Txtphone.Text, Convert.ToDateTime(Txtbirthday.Text), ddlgender.Text, ddlsecurityQuestion.SelectedValue, Txtanswer.Text);
            //Clear();
        }
        else
        {
            lbl_msg.Text = "please accept the terms";
        }
    }


    protected void Txtusername_TextChanged(object sender, EventArgs e)
    {

        Member user = new Member();

        if (!string.IsNullOrEmpty(Txtusername.Text))
        {
               if (user.Emailavi(Txtusername.Text))
            {
                ImgUser.ImageUrl = "../NotAvailable.gif";
                lbl_msg.Text = "NotAvailable user";
                lbl_msg.ForeColor = System.Drawing.Color.Red;
                Txtusername.Focus();

            }
            else
            {
                ImgUser.ImageUrl = "../Icon_Available.gif";
                lbl_msg.Text = "Available user";
                lbl_msg.ForeColor = System.Drawing.Color.Green;
            }
        }
    }


    protected void Txtemail_TextChanged(object sender, EventArgs e)
    {
        Member emailcheck = new Member();

        if (!string.IsNullOrEmpty(Txtemail.Text))
        {

                              string email = Txtemail.Text;
                              Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                              Match match = regex.Match(email);

        if (match.Success)
    {

                if (emailcheck.Emailavi(Txtemail.Text))
            {
                Imgemail.ImageUrl = "../NotAvailable.gif";
                lbl_msg.Text = "NotAvailable email";
                lbl_msg.ForeColor = System.Drawing.Color.Red;

            }
                else
            {
                Imgemail.ImageUrl = "../Icon_Available.gif";
                lbl_msg.Text = "Available email";
                lbl_msg.ForeColor = System.Drawing.Color.Green;

            }
        }


        else
            Imgemail.ImageUrl = "../NotAvailable.gif";
            lbl_msg.Text = "Not vaild email";
            lbl_msg.ForeColor = System.Drawing.Color.Red;
            Txtemail.Focus();
    }

        else
        {
            lbl_msg.Text = "Please enter an email";
            lbl_msg.ForeColor = System.Drawing.Color.Red;
            Txtemail.Focus();
        }
    }
}
Posted

It shoud work... I will send you a working code using the jquery datepicker... Implement it if it does what you want.


JavaScript
 $(document).ready(function () {


    AjaxEnds();
    if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AjaxEnds);
    }
});  

function AjaxEnds() { 
    BindDatePicker(); 
}
function BindDatePicker() {
    if ($(".txtDate").length > 0)
        $(".txtDate").datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, showAnim: 'clip', yearRange: "-1000:+1" });

    if ($(".txtDateTime").length > 0)
        $(".txtDateTime").datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, showAnim: 'clip', showTime: true, duration: '', yearRange: "-1000:+1" });

    if ($(".txtDateNow").length > 0) {
        $(".txtDateNow").datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, showAnim: 'clip', yearRange: "-1000:+1" });
        $(".txtDateNow").datepicker("setDate", new Date());
    }

    if ($(".txtTimeNow").length > 0) {
        $(".txtTimeNow").ptTimeSelect({
            hoursLabel: 'Hour',
            minutesLabel: 'Minutes',
            setButtonLabel: 'Set',
            onFocusDisplay: true,
            zIndex: 10

        });
    }
}


Download jquery datepicker and ptTimeSelect.. and add them in html header, like you did in your question, based on what you asked you already know how to add the jquery to your page.. I hope this helps you..
Regards,

Ibrahim Karakira
 
Share this answer
 
Comments
ost3z 19-Jul-13 5:41am    
thanks its really work many thankx for your help
ibrahim karakira 19-Jul-13 5:46am    
Please if it worked press the button to that says my answer is correct :) and rate me.. Thank you alot :D
test this instead of your javascript; This should handle the ajax call and rebind the calender on Ajax call :).

JavaScript
$(document).ready(function () {
    AjaxEndMethod(); 
    if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AjaxEndMethod);
    }
});

function AjaxEndMthod() {
   $("#<%=Txtbirthday.ClientID %>").dynDateTime({
            showsTime: true,
            ifFormat: "%Y/%m/%d %H:%M",
            daFormat: "%l;%M %p, %e %m, %Y",
            align: "BR",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
            button: ".next()"
        });
}



Regards,
Ibrahim Karakira
 
Share this answer
 
Comments
ost3z 18-Jul-13 13:54pm    
thank you for your reply it never works at all it stopped the calender

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