Calendar popup idea

Last post 10-27-2008 7:11 AM by hashad. 15 replies.

Sort Posts:

  • Calendar popup idea

    10-21-2008, 10:46 AM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    I am trying to use a calendar popup "<asp:calendar>" but use the same view page that has the image of the calendar. Basically I want an image of a calendar to display in my view and when clicked an actual calendar will display and whatever value is clicked will populate in the textbox and I want all this to be coded in under one view page.Is this possible? Other responses O seen to accomplish part of this was having a default view and a calendar view.

  • Re: Calendar popup idea

    10-21-2008, 10:56 AM
    • Member
      275 point Member
    • gpgpu
    • Member since 06-06-2006, 5:28 PM
    • Posts 62

    You can use the CalendarExtender control from Ajax Control Toolkit.

  • Re: Calendar popup idea

    10-21-2008, 10:57 AM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    I'm not using ajax

  • Re: Calendar popup idea

    10-21-2008, 11:11 AM
    Answer
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51

    hii

    first make js file with name popUp

    put ths code in popUp.js

    var popUp; 
    
    function OpenCalendar(idname, postBack)
    
    {
    
    popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
    
    '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
    
    'popupcal', 
    
    'width=165,height=208,left=200,top=250');
    
    }
    
    function SetDate(formName, id, newDate, postBack)
    
    {
    
    eval('var theform = document.' + formName + ';');
    
    popUp.close();
    
    theform.elements[id].value = newDate;
    
    if (postBack)
    
    __doPostBack(id,'');
    
    } 
    
    then call the popup.js in your head of page

    <script language="javascript" src="js/PopUp.js" type="text/javascript">

    </script>

     and put img on your pageto call the calender from js file

    <a href="javascript:;" onclick="window.open('PopUpVivek.aspx?textbox=TextBox1','cal','width=115,height=165,left=270,top=180')">

    <img id="Img" runat="server" border="0" src="images/PopUpCalendar.gif" style="font-size: 9pt; font-family: Tahoma; color: dimgray;" /></a>

     

    hope it's help you

    if it help don't forget to mark as answer

    thank you iam wait your replay

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-21-2008, 11:11 AM
    Answer
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51

    hii

    first make js file with name popUp

    put ths code in popUp.js

    var popUp; 
    
    function OpenCalendar(idname, postBack)
    
    {
    
    popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
    
    '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
    
    'popupcal', 
    
    'width=165,height=208,left=200,top=250');
    
    }
    
    function SetDate(formName, id, newDate, postBack)
    
    {
    
    eval('var theform = document.' + formName + ';');
    
    popUp.close();
    
    theform.elements[id].value = newDate;
    
    if (postBack)
    
    __doPostBack(id,'');
    
    } 
    
    then call the popup.js in your head of page

    <script language="javascript" src="js/PopUp.js" type="text/javascript">

    </script>

     and put img on your pageto call the calender from js file

    <a href="javascript:;" onclick="window.open('PopUpVivek.aspx?textbox=TextBox1','cal','width=115,height=165,left=270,top=180')">

    <img id="Img" runat="server" border="0" src="images/PopUpCalendar.gif" style="font-size: 9pt; font-family: Tahoma; color: dimgray;" /></a>

     

    hope it's help you

    if it help don't forget to mark as answer

    thank you iam wait your replay

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-21-2008, 11:53 AM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name

     onclick="window.open('PopUpVivek.aspx?

    Those are using two different views. Meaning I would have to create a new view page named calendar.aspx to make this work right,and I am assuming that PopUpVivek.aspx should be named my default view"default.aspx". I wasn't trying to create another view page or am I not understanding this example correctly? Also instead of making a js file couldn't I just paste the js code at the top of my default view inside javascript tags instead of importing it as a source?

  • Re: Calendar popup idea

    10-21-2008, 3:02 PM
    Answer
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51

    sorry for my mistake

    chang

    popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name

    to

    popUp = window.open('PopUpVivek.aspx?formname=' + document.forms[0].name

     

    and in PopUpVivek.aspx in source put

                <asp:Calendar id="CalVivek" nSelectionChanged="Change_Date" runat="server" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 4px; font-size: 9pt; color: dimgray; font-family: arial;" onselectionchanged="CalVivek_SelectionChanged" Height="1px" Width="1px">

    and in c# put

    protected void CalVivek_SelectionChanged(object sender, System.EventArgs e)
            {
                if (Request.QueryString["textbox"] != "")
                {
                    string strScript = "<script>window.opener.document.forms(0)." + Request.QueryString["textbox"].ToString() + ".value = '";
                    strScript += CalVivek.SelectedDate.ToString("yyyy/MM/dd");
                    strScript += "';self.close()";
                    strScript += "</" + "script>";
                    RegisterClientScriptBlock("Calendar_ChangeDate", strScript);
                }
            

    that is all

    wait for your reply

     

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-21-2008, 4:00 PM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    Forgot to mention that I am using MVC!!! Probably should have mentioned that first. But what I take that you are saying is that in my default.aspx I should have:

    <asp:textbox id="txtTo" runat="server" Columns="10" MaxLength="10" CssClass="smInput"></asp:textbox>

    <a href="javascript:;" onclick="window.open('calendar?textbox=txtTo','cal','width=115,height=165,left=270,top=180')">

    <img id="Img" runat="server" border="0" src="/Content/img/calendar.gif" style="font-size: 9pt; font-family: Tahoma;

    " /></a>

    and instead of calling it popupvivek I called it calendar.aspx and I should have:

    public partial class calendar : ViewPage

    {

    protected void CalVivek_SelectionChanged(object sender, System.EventArgs e)

    {

    if (Request.QueryString["textbox"] != "")

    {

    string strScript = "<script>window.opener.document.forms(0)." + Request.QueryString["textbox"].ToString() + ".value = '";

    strScript += CalVivek.SelectedDate.ToString("yyyy/MM/dd");

    strScript += "';self.close()";

    strScript += "</" + "script>";

    RegisterClientScriptBlock("Calendar_ChangeDate", strScript);

    }

    }

    }

    <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <script language="javascript" type="text/javascript" >
    var popUp; function OpenCalendar(idname, postBack)

    {

    popUp = window.open('calendar.aspx?formname=' + document.forms[0].name +

    '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack,

    'popupcal',

    'width=165,height=208,left=200,top=250');

    }

    function SetDate(formName, id, newDate, postBack)

    {

    eval(
    'var theform = document.' + formName + ';');

    popUp.close();

    theform.elements[id].value = newDate;

    if (postBack)__doPostBack(id,'');

    }

    </script>

    <asp:Calendar id="CalVivek" nSelectionChanged="Change_Date" runat="server" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 4px; font-size: 9pt;

    font-family: arial;" onselectionchanged="CalVivek_SelectionChanged" Height="1px" Width="1px"/>

     

     

    </asp:Content>

    By doing that I receive an "Object reference not set to an instance of an object." error because first i was receiving an "calendar.aspx method not found on the controller" error before I changed the

    <a href="javascript:;" onclick="window.open('calendar.aspx?textbox=txtTo','cal','width=115,height=165,left=270,top=180')"> to

    <a href="javascript:;" onclick="window.open('calendar?textbox=txtTo','cal','width=115,height=165,left=270,top=180')">

    and I put below in my defaultcontroller.cs

    public ActionResult calendar()

    {

    return View();

    }

  • Re: Calendar popup idea

    10-21-2008, 5:00 PM
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51

    man i will give you me files its wooooork

    hope it help you

    download

     wait your reply

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-21-2008, 5:15 PM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    Was that link meant to send me to:http://rapidshare.com/files/156266784/popup_calender.rar

    because that opens a site to rapidshare asking for me to subscribe for filesharing because the download limit ran out

  • Re: Calendar popup idea

    10-21-2008, 5:40 PM
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51
    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-21-2008, 5:43 PM
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51
    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-22-2008, 10:52 AM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59

    Yeah, half of this is working after I had to make some few changes since Im using MVC, but for some reason it is not going into the textbox field. I believe it is because the javascript is never being executed:

    function OpenCalendar(idname, postBack)

    {

    popUp = window.open(
    'calendar?formname=' + document.forms[0].name +

    '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack,

    'popupcal', 'width=165,height=208,left=200,top=250');

    }

    function SetDate(formName, id, newDate, postBack)

    {

    eval(
    'var theform = document.' + formName + ';');

    popUp.close();

    theform.elements[id].value = newDate;

    if (postBack)__doPostBack(id,'');

    }

    There is no where in the code that you sent that is calling either of those javascript functions

  • Re: Calendar popup idea

    10-22-2008, 7:06 PM
    • Member
      202 point Member
    • hashad
    • Member since 07-02-2005, 9:08 PM
    • egypt
    • Posts 51

    TStamper

    did you run my code?

    is it work or is there an error?

    i made it like this and it's work for me

    hope it help you two

    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Calendar popup idea

    10-23-2008, 10:50 AM
    • Member
      6 point Member
    • TStamper
    • Member since 10-20-2008, 4:48 PM
    • Posts 59
    Yeah it works if you're just using a regular web application and I actually notice that the javascript file is not needed, but since I am using MVC the communication is a little different. So do you know how to make it work using MVC?
Page 1 of 2 (16 items) 1 2 Next >