CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 1/26/2008 4:44:18 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 13 Views: 40 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
14 Items, 1 Pages 1 |< << Go >> >|
storm721984
Asp.Net User
Master page, javascript and pop-up calender1/26/2008 4:44:18 PM

0/0

I'm very new in javascript and basically just understood the concept of master page.. So this is the problem i face...

I google around to create a pop-up calender and found sample of source code using javascript. The code somehow work but not in web page that uses master page....

Below is the code that i use:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Calender3.aspx.cs" Inherits="Calender3" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript">

function openCalendar()

{

var testtt = document.getElementById("ttt");

var site = "Calender2.aspx?textbox=" + testtt.value;

window.open(site,'cal','width=220,height=200,left=270,top=180')

}

</script>

<asp:Textbox id="tbMyDate" runat="server" Width="80px"></asp:textbox>

<asp:Textbox id="tbMyDate2" runat="server" Width="80px"></asp:textbox>

<input id="ttt" type="image" value="tbMyDate&textbox2=tbMyDate2" onclick="openCalendar()" src="calendar.gif"/>

</asp:Content>

 =====================================================================================

 

protected void Change_Date(System.Object sender, System.EventArgs e)

{

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

{

CalPopup.SelectedDate.ToString(
"dd MMM");

}

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

{

string strScript =

"<script>window.opener.document.forms[0]." +

Request.QueryString["textbox"].ToString() + ".value = '" +

CalPopup.SelectedDate.ToString("dd MMM") +

"';" + " window.opener.document.forms[0]." +

Request.QueryString["textbox2"].ToString() + ".value = '" +

CalPopup.SelectedDate.ToString("dddd") + "';" + "self.close()" +

"</" + "script>";

RegisterClientScriptBlock("Calendar_ChangeDate", strScript);

}

}

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 5:40:18 PM

0/0

Hello, Can you please post your master page contents?

From what I can tell your code looks fine so I am picking there is conflict from the master page.




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 5:52:07 PM

0/0

I forget to mention that Calender3.aspx uses master page while Calender2.aspx didn't use master page. As the Calender2.aspx is where the calender selection control is located.

The problem i face is once i select a date on the calender it just doesn't seem to close and no value is return on two of the textbox located inside Calender3.aspx

This is the source code on my master page which i can say its quite empty:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table>

<tr>

<td>

<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">

</asp:contentplaceholder>

</td>

</tr>

<tr>

<td>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 6:01:38 PM

0/0

 

var site = "Calender2.aspx?textbox=" + testtt.value;

Should this be Calender3.aspx

 




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 6:12:41 PM

0/0

Nope...
that part of code stored in Calender3.aspx is actually functioning fine which it actually open another page which is Calender2.aspx that doesn't use master page and it display the calender for user to select. Once user has select the date wanted, the coding in Calender2.aspx will send the value back to Calender3.aspx textbox and close Calender2.aspx

So the problem here is that value cannot be send back to Calender3.aspx and it doesn't close as well...

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 6:33:46 PM

0/0

ok so let me no if im on the right track or not lol. 

So the query is not being passeed from 2.aspx to 3.aspx

Is there a fire statement in 2.aspx to create the query?

Better yet lol whats the code look like?




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 6:43:11 PM

0/0

Well to make things easier

this is what stored in Calender3.aspx which only has source code

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Calender3.aspx.cs" Inherits="Calender3" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript">

function openCalendar()

{

var testtt = document.getElementById("ttt");

var site = "Calender2.aspx?textbox=" + testtt.value;

window.open(site,'cal','width=220,height=200,left=270,top=180')

}

</script>

<asp:Textbox id="tbMyDate" runat="server" Width="80px"></asp:textbox>

<asp:Textbox id="tbMyDate2" runat="server" Width="80px"></asp:textbox>

<input id="ttt" type="image" value="tbMyDate&textbox2=tbMyDate2" onclick="openCalendar()" src="calendar.gif"/>

</asp:Content>

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This is Calender2.aspx which has source code and coding in Calender2.aspx.cs:

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

<!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>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:Calendar id="CalPopup" OnSelectionChanged="Change_Date"

runat="server" backcolor="#FFFFCC" width="220px" daynameformat="FirstLetter"

forecolor="#663399" height="200px" font-size="8pt" font-names="Verdana"

bordercolor="#FFCC66" BorderWidth="1px" ShowGridLines="True">

<TodayDayStyle ForeColor="White" BackColor="#FFCC66"></TodayDayStyle>

<SelectorStyle BackColor="#FFCC66"></SelectorStyle>

<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC"></NextPrevStyle>

<DayHeaderStyle Height="1px" BackColor="#FFCC66"></DayHeaderStyle>

<SelectedDayStyle Font-Bold="True" BackColor="#CCCCFF"></SelectedDayStyle>

<TitleStyle Font-Size="9pt" Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></TitleStyle>

<OtherMonthDayStyle ForeColor="#CC9966"></OtherMonthDayStyle>

</asp:Calendar>

</div>

</form>

</body>

</html>

-----------------------------------------------------------------------------------------------------------------------------------------------------------

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Calender2 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Change_Date(System.Object sender, System.EventArgs e)

{

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

{

CalPopup.SelectedDate.ToString(
"dd MMM");

}

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

{

string strScript =

"<script>window.opener.document.forms[0]." +

Request.QueryString["textbox"].ToString() + ".value = '" +

CalPopup.SelectedDate.ToString("dd MMM") +

"';" + " window.opener.document.forms[0]." +

Request.QueryString["textbox2"].ToString() + ".value = '" +

CalPopup.SelectedDate.ToString("dddd") + "';" + "self.close()" +

"</" + "script>";

RegisterClientScriptBlock("Calendar_ChangeDate", strScript);

}

}

}

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/26/2008 8:44:09 PM

0/0

Ok here is my correction list.

  • Rename all instances of "Calender" with "Calendar"
  • In the page Calendar3.aspx replace the page load and ad the script block (even though its empty)
  • Replace entire Calendar2.aspx page with contents provided.

 

 Calendar3.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Calendar" EnableEventValidation="true" %>

<script runat="server">

</script>

--------------------------------------------------------------

Calendar2.aspx

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

 

<html>

<head>

<title>Calendar</title>

</head>

<body>

<form runat="server"><div>

<asp:Calendar id="CalPopup" OnSelectionChanged="Change_Date"

runat="server" backcolor="#FFFFCC" width="220px" daynameformat="FirstLetter"

forecolor="#663399" height="200px" font-size="8pt" font-names="Verdana"

bordercolor="#FFCC66" BorderWidth="1px" ShowGridLines="True">

<TodayDayStyle ForeColor="White" BackColor="#FFCC66"></TodayDayStyle>

<SelectorStyle BackColor="#FFCC66"></SelectorStyle>

<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC"></NextPrevStyle>

<DayHeaderStyle Height="1px" BackColor="#FFCC66"></DayHeaderStyle>

<SelectedDayStyle Font-Bold="True" BackColor="#CCCCFF"></SelectedDayStyle>

<TitleStyle Font-Size="9pt" Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></TitleStyle>

<OtherMonthDayStyle ForeColor="#CC9966"></OtherMonthDayStyle>

</asp:Calendar>

</div>

</form>

</body>

</html>




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/27/2008 5:54:08 AM

0/0

Sorry to say i don't really understand....

Is there any other method i can do to get a workable pop-up calender function that work on pages that has master page?

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/27/2008 6:48:23 AM

0/0

 

Your pop up calendar works fine for me. All you need to do is correct the spelling mistakes such as calendar is Not spelt calender. If you correct your page names and also the code that references the incorrect spelling (as there are instances of the correct spelling) and also complete the other tasks that I listed for you then you will find that your application works just fine.

Regards




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/27/2008 7:47:31 AM

0/0

Basically the instruction you gave me require me to code like this

<script runat="server">

function openCalendar()

{

var testtt = document.getElementById(
"ttt");

var site = "CalendarPopUp.aspx?textbox=" + testtt.value;

window.open(site,'cal','width=220,height=200,left=270,top=180');

}

</script>

 OR like this:

 

<script runat="server">

</script>

As i receive error when i place in the code... mostly on the code:

 window.open(site,'cal','width=220,height=200,left=270,top=180');

Spider Master
Asp.Net User
Re: Master page, javascript and pop-up calender1/27/2008 9:45:58 AM

0/0

No I said

  • In the page Calendar3.aspx replace the page load and ad the script block (even though its empty)
Calendar3.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Calendar" EnableEventValidation="true" %>

<script runat="server">

</script>

<!--That above is a script block -->




"If I have answered your question please mark as answer"


Hosting General | Product Catalogue | Traffic Facts | Quick Blog Cast | Virtual Dedicated Servers | Dedicated Servers
Amanda Wang - M
Asp.Net User
Re: Master page, javascript and pop-up calender1/28/2008 10:53:01 AM

0/0

Hi,

Base on your description, you want to pop out a clalender when you click on the textbox, and close the calender page after you chose the data in the content page, right?

Because you use the master page, you should use the control's  clientid when you use getElementById

Below is my sample code,

1. The master page:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage_MasterPage" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" method=post>
    <table>
  <tr>
    <td align="right">
      Start Date:
    </td>
    <td align="left">

    </td>
    <td align="center">

    </td>
  </tr>
  <tr>
    <td align="right">
      End Date:
    </td>
    <td align="left">

    </td>
    <td align="center">
    </td>
  </tr>
</table>
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </div>
    </form>
</body>
</html>

2. The content page:
<%@ Page Language="VB" MasterPageFile="~/MasterPage/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="MasterPage_Default" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="TextBox1" runat="server" onclick="window.open('../popup.aspx?textbox=ctl00$txtStartDate','cal','width=250,height=225,left=270,top=180')"></asp:TextBox>
 </asp:Content>

3. The calender page:

<%@ Page Language="vb" AutoEventWireup="false" Src="PopUp.aspx.vb" Inherits="DotNetJohn.PopUp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>PopUp</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Calendar ID="calDate" OnSelectionChanged="Change_Date" Runat="server" />
<input type="hidden" id="control" runat="server" />
</form>
</body>
</html>

4. The codebehind of the calender page:

Imports System.Web.UI.HtmlControls.HtmlGenericControl

Namespace DotNetJohn

  Public Class PopUp
    Inherits System.Web.UI.Page

    Protected WithEvents control As System.Web.UI.HtmlControls.HtmlInputHidden
    Protected WithEvents calDate As System.Web.UI.WebControls.Calendar

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      control.Value = Request.QueryString("textbox").ToString()
    End Sub

    Protected Sub Change_Date(sender As System.Object, e As System.EventArgs)
            Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
            strScript += calDate.SelectedDate.ToString("MM/dd/yyyy")
            strScript += "';self.close()"
            strScript += "</" + "script>"
            RegisterClientScriptBlock("anything", strScript)
    End Sub

  End Class

End Namespace

storm721984:
The problem i face is once i select a date on the calender it just doesn't seem to close and no value is return on two of the textbox located inside Calender3.aspx

About your problem, your refer the calender's codebehind.

 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
storm721984
Asp.Net User
Re: Master page, javascript and pop-up calender1/31/2008 2:27:15 AM

0/0

Thanks for all your help and sorry for the late reply as i was sick.....

I somehow figure out that all i need to change on the script and it work fine. Yet thanks again for all your help Wink

Below is the sample code that i got it working:

window.opener.document.forms[0].ctl00_ContentPlaceHolder1_" +

Request.QueryString["textbox2"].ToString() + ".value = '" +

CalPopup.SelectedDate.ToString("dddd") + "';" + "self.close()"

14 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
CSS Instant Results Authors: Richard York, Pages: 383, Published: 2006

Web:
popup calendar when using Masterpage Reload this Page popup calendar when using Masterpage ... Dim strjscript As String = "




Search This Site:










server.mappath in a class file

how to compile?

custom textboxes and validator control

file upload: without using file input control

adding special characters in plain text on asp.net page

runtime error

project templates error

how to store user information ??

page not displaying sitemaster and css layout/format

scrollable content page

vs 2005 error: unable to open the web... [need help!]

forms authentication, collation problem

createuserwizard customization

archiectect

memory

setting timeout

no blog posting with top level categories?

2 lines before header, how?

active directory login

opening new window, how?

refactoring, unit testing, and test-driven development

configuration error

master page trace problem

backup the database

webadmin.master parse error

using relative paths for style sheet and masterpages

skin inheriting another skin?

how to add independent aspx files to dnn

how does the software redirect to login.aspx?

[!?!] regular expression

 
All Times Are GMT