Advertisement

06.03.2008 at 11:35PM PDT, ID: 23455734
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Javascript and ASP.Net Calendar

Asked by digitalZo in JavaScript, Cascading Style Sheets (CSS), Programming for ASP.NET

I have made a UserControl with an ASP.Net calendar with a little dose of Javascript. The problem is that since I've set the div style display to none, when I click on the img button, the calendar doesnt open. If I remove that style it opens, but then doesn't close when I select a date.

Even if the calendar pops up, when I click on month and year the calendar disappears due to autopostback which I don't want it to happen.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
Calendar.acsx
 
<asp:TextBox ID="txt_date" runat="server" Width="138px"></asp:TextBox>
<asp:ImageButton ID="img_date" runat="server" ImageUrl="~/date.png" style="left: 1px; position: relative; top: 4px" OnClientClick="ShowTxt('Calendar1_date_div'); return false;" />
 
<script type="text/javascript" language="javascript">
 function ShowTxt(id)
            {
              if (document.getElementById(id).style.display == 'none')
              {
              document.getElementById(id).style.display = "block";
              }
              else
              {
              document.getElementById(id).style.display = "none";
              }
          
             }
 
</script>
 
<div id="date_div" runat="server" style="z-index:200; position: absolute; top:15%; left:1%; border: 1px solid #006699; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=92)progid:DXImageTransform.Microsoft.Glow(Color=#006699,Strength=5);">
<table style="background-color: #006699; width: 157px; height: 227px;">
<tr>
    <td align="center" style="width: 223px;">
    <asp:DropDownList ID="ddl_month" runat="server" AutoPostBack="true" Font-Names="Verdana" Font-Size="8pt"></asp:DropDownList>
    <asp:DropDownList ID="ddl_year" runat="server" AutoPostBack="true" Font-Names="Verdana" Font-Size="8pt"></asp:DropDownList>
    </td>
</tr>
<tr>
    <td style="width: 223px">
        <asp:Calendar ID="cal_date" runat="server" BackColor="White" BorderColor="#006699" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="#006699" Height="182px" Width="193px" NextMonthText="" PrevMonthText="">
            <SelectedDayStyle BackColor="#76ACC8" Font-Bold="True" ForeColor="White" />
            <SelectorStyle BackColor="#006699" ForeColor="White" />
            <WeekendDayStyle BackColor="#006699" ForeColor="White" />
            <OtherMonthDayStyle ForeColor="DarkGray" />
            <NextPrevStyle Font-Size="8pt" ForeColor="White" />
            <DayHeaderStyle BackColor="#76ACC8" ForeColor="White" Height="1px" />
            <TitleStyle BackColor="#006699" BorderWidth="1px" Font-Bold="True" Font-Size="10pt"
                ForeColor="White" Height="25px" />
           
         </asp:Calendar>
    </td>
</tr>
</table>
</div>
 
-----------------
 
Calendar acsx.vb
 
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Populate_MonthList()
            Populate_YearList()
        End If
    End Sub
 
    Sub Populate_MonthList()
        'Add each month to the list
        ddl_month.Items.Add("January")
        ddl_month.Items.Add("February")
        ddl_month.Items.Add("March")
        ddl_month.Items.Add("April")
        ddl_month.Items.Add("May")
        ddl_month.Items.Add("June")
        ddl_month.Items.Add("July")
        ddl_month.Items.Add("August")
        ddl_month.Items.Add("September")
        ddl_month.Items.Add("October")
        ddl_month.Items.Add("November")
        ddl_month.Items.Add("December")
 
 
        'Make the current month selected item in the list
        ddl_month.Items.FindByValue(MonthName(DateTime.Now.Month)).Selected = True
 
    End Sub
    Sub Populate_YearList()
        Dim intYear As Integer
 
        'Year list can be changed by changing the lower and upper 
        'limits of the For statement    
        For intYear = DateTime.Now.Year - 8 To DateTime.Now.Year + 8
            ddl_year.Items.Add(intYear)
        Next
 
        'Make the current year selected item in the list
        ddl_year.Items.FindByValue(DateTime.Now.Year).Selected = True
 
    End Sub
 
    Protected Sub ddl_month_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_month.SelectedIndexChanged, ddl_year.SelectedIndexChanged
        cal_date.TodaysDate = CDate(ddl_month.SelectedItem.Value & _
                                               " 1, " & ddl_year.SelectedItem.Value)
    End Sub
 
 
    Protected Sub cal_date_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cal_date.SelectionChanged
        txt_date.Text = cal_date.SelectedDate.Day & "/" & cal_date.SelectedDate.Month & "/" & ddl_year.SelectedValue
        date_div.Style.Add("display", "none")
    End Sub
End Class
[+][-]06.03.2008 at 11:42PM PDT, ID: 21707447

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 11:54PM PDT, ID: 21707512

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 10:11PM PDT, ID: 21716557

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Cascading Style Sheets (CSS), Programming for ASP.NET
Sign Up Now!
Solution Provided By: digitalZo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628