Click here to Skip to main content
15,888,802 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDetermining all possible AD login return types (i.e. User Not Found, etc.) from a MVC json web service Pin
Stephen Holdorf15-Sep-14 13:36
Stephen Holdorf15-Sep-14 13:36 
Questionweb.config Pin
Member 1108003313-Sep-14 5:40
Member 1108003313-Sep-14 5:40 
AnswerRe: web.config Pin
jkirkerx15-Sep-14 7:09
professionaljkirkerx15-Sep-14 7:09 
AnswerRe: web.config Pin
Sibeesh KV29-Sep-14 1:18
professionalSibeesh KV29-Sep-14 1:18 
Questionasp.net membership Pin
msc92013-Sep-14 3:48
msc92013-Sep-14 3:48 
AnswerRe: asp.net membership Pin
hypermellow18-Sep-14 5:32
professionalhypermellow18-Sep-14 5:32 
GeneralRe: asp.net membership Pin
msc92022-Sep-14 0:55
msc92022-Sep-14 0:55 
QuestionJquery-ui ASP Update Panels and User Controls Pin
Wierdbeard6512-Sep-14 7:08
Wierdbeard6512-Sep-14 7:08 
Hi,

First up, I have spent the past 2 days Googling this one. I have found many, many "solutions" but I can't get any of them to work. Part of the problem is that the solutions say to use this code or that, but don't say WHERE to put it!

So, here is the situation.

I have a page, using a Master page. I have a TreeView on the left and an Update Panel on the right. When the user selects a node in the TreeView, I add a user control to the Update Panel. (The control depends upon the type of the node - internal to my App.)

This works.

BUT, I have the need to enter a date in a User Control. I tried to use the standard Calendar control, but for some reason it's SelectedDate property isn't being updated. I then tried the JQuery-UI DatePicker tied to a text box, but it never pops up.

I know it has something to do with the AJAX reload of the Panel happening after the control is registered, but...

Anyway, if anyone can explain how to do it (not just what code to use, but WHERE to place it Smile | :) ) I'd be eternally grateful!

Here is what I have (I have a Calendar control in there too. Getting either to work would make me VERY happy!):
Site.Master:
ASP.NET
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Shedulinator.SiteMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">

<! While developing! >
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<! End dev bit>
    <title>Interactive Intelligence Education Department Schedulinator</title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    <script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.11.1.js" type="text/javascript"></script>
    </asp:ContentPlaceHolder>
    <script type="text/javascript">
        $(document).ready(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

            function EndRequestHandler(sender, args) {
                $('.SiteDatePicker').datepicker({ dateFormat: 'dd-mm-yy' });
            }

        });
    </script> </head>
<body>
    <form runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
Page Title
                </h1>
            </div>
            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                    <AnonymousTemplate>
                        [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
                    </LoggedInTemplate>
                </asp:LoginView>
            </div>
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
        
    </div>
    </form>
</body>
</html>


User Control:
ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CourseEditor.ascx.cs"
    Inherits="Shedulinator.TheSettings.CourseEditor" %>
<% if (false)
   { %>
<link rel="Stylesheet" type="text/css" href="../Styles/Site.css" />
<% } %>   <script type="text/javascript">

              $(function () {

                  $('#<%=TextBoxGoLive.ClientID %>').datepicker();

              });  

       </script>
<asp:Panel ID="Panel1" runat="server" CssClass="SettingsFormPanel">
    <asp:Table ID="Table1" runat="server">
        <asp:TableRow runat="server">
            <asp:TableCell runat="server" RowSpan="6">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/106660-3d-glossy-orange-orb-icon-transport-travel-compass2.png"
                    CssClass="SettingsIcon" />
            </asp:TableCell>
            <asp:TableCell runat="server">
                <asp:Label ID="CourseRegion" runat="server" Text="Course Title:"></asp:Label></asp:TableCell>
            <asp:TableCell runat="server">
                <asp:TextBox ID="TextBoxCourseTitle" runat="server"></asp:TextBox>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server">
                <asp:Label ID="LabelDuration" runat="server" Text="Duration"></asp:Label></asp:TableCell>
            <asp:TableCell runat="server">
                <asp:TextBox ID="TextBoxDuration" runat="server"></asp:TextBox>
            </asp:TableCell></asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server">
                <asp:Label ID="LabelDayLength" runat="server" Text="Day Length"></asp:Label></asp:TableCell><asp:TableCell
                    runat="server">
                    <asp:TextBox ID="TextBoxDayLength" runat="server"></asp:TextBox>
                </asp:TableCell></asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server">
                <asp:Label ID="LabelIsVirtual" runat="server" Text="Web Based"></asp:Label></asp:TableCell><asp:TableCell
                    runat="server">
                    <asp:CheckBox ID="CheckBoxIsVirtual" runat="server" /></asp:TableCell></asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server">
                <asp:Label ID="LabelGoLive" runat="server" Text="Go Live"></asp:Label></asp:TableCell><asp:TableCell
                    runat="server">
                    <asp:TextBox ID="TextBoxGoLive" runat="server" CssClass="SiteDatePicker"></asp:TextBox>
                </asp:TableCell></asp:TableRow>
        <asp:TableRow runat="server">
            <asp:TableCell runat="server">
                <asp:Label ID="LabelRetiredFrom" runat="server" Text="Retired From"></asp:Label></asp:TableCell><asp:TableCell
                    runat="server">
                    <asp:Calendar ID="CalendarRetired" runat="server" BackColor="White"></asp:Calendar>
                </asp:TableCell></asp:TableRow>
    </asp:Table>
    <asp:Button ID="ButtonCancel" runat="server" CssClass="SettingsButton" Text="Cancel"
        OnClick="ButtonCancel_Click" />
    <asp:Button ID="ButtonOK" runat="server" CssClass="SettingsButton" Text="OK" OnClick="ButtonOK_Click" />
</asp:Panel>

Code behind for User Control:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Shedulinator.TheSettings
{
    public partial class CourseEditor : SettingsForm
    {
        public event EventHandler Submit;
        public event EventHandler CancelClick;

        protected void Page_Load(object sender, EventArgs e)
        {
            reload();
        }
        protected void reload()
        {
            int CourseID = 0;
            if (ItemID != null)
            {
                CourseID = Int16.Parse(ItemID);
            }
            if (CourseID > 0)
            {
                Course c;
                using (SchedulerDatabaseDataContext dc = new SchedulerDatabaseDataContext())
                {
                    c = dc.Courses.Where(Course => Course.CourseID == CourseID).Single();
                }
                TextBoxCourseTitle.Text = c.CourseTitle;
                TextBoxDayLength.Text = c.DayLength.ToString();
                TextBoxDuration.Text = c.Duration.ToString();
                CheckBoxIsVirtual.Checked = (c.IsVirtual == 'Y');
                if (c.Retired == null)
                {
                    CalendarRetired.VisibleDate = DateTime.Today;
                    CalendarRetired.SelectedDates.Clear();
                }
                else
                {
                    CalendarRetired.VisibleDate = (DateTime)c.Retired;
                    CalendarRetired.SelectedDate = (DateTime)c.Retired;
                }
            }
            else
            {
                TextBoxCourseTitle.Text = "";
                TextBoxDayLength.Text = "8";
                TextBoxDuration.Text = "5";
                CheckBoxIsVirtual.Checked = false;
                CalendarRetired.VisibleDate = DateTime.Today;
                CalendarRetired.SelectedDates.Clear();
            }
        }

        protected void ButtonCancel_Click(object sender, EventArgs e)
        {
            reload();
            if (CancelClick != null)
            {
                CancelClick(this, new EventArgs());
            }
        }

        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            using (SchedulerDatabaseDataContext dc = new SchedulerDatabaseDataContext())
            {
                int CourseID = 0;
                if (ItemID != null)
                {
                    CourseID = Int16.Parse(ItemID);
                }
                Course c;
                if (CourseID == -1)
                {
                    c = new Course();
                    dc.Connection.Open();
                    Course C = dc.Courses.OrderByDescending(Course => Course.CourseID).FirstOrDefault();
                    c.CourseID = (null == C ? 0 : C.CourseID) + 1;
                }
                else
                {
                    c = dc.Courses.Where(Course => Course.CourseID == CourseID).Single();
                }
                c.CourseTitle = TextBoxCourseTitle.Text;
                c.Duration = int.Parse(TextBoxDuration.Text);
                c.DayLength = int.Parse(TextBoxDayLength.Text);
                c.IsVirtual = (CheckBoxIsVirtual.Checked ? 'Y' : 'N');
                if (CalendarRetired.SelectedDates.Count>0)
                {
                    c.Retired = CalendarRetired.SelectedDate;
                }
                if (CourseID == -1)
                {
                    dc.Courses.InsertOnSubmit(c);
                }
                dc.SubmitChanges();

            }
            if (Submit != null)
            {
                Submit(this, new EventArgs());
            }
        }
    }
}

Paul

AnswerJquery DatePicker Pin
jkirkerx15-Sep-14 9:37
professionaljkirkerx15-Sep-14 9:37 
GeneralRe: Jquery DatePicker Pin
Wierdbeard6520-Sep-14 12:18
Wierdbeard6520-Sep-14 12:18 
GeneralRe: Jquery DatePicker Pin
jkirkerx20-Sep-14 12:40
professionaljkirkerx20-Sep-14 12:40 
QuestionError: The resource cannot be found. Pin
Member 876166711-Sep-14 8:42
Member 876166711-Sep-14 8:42 
AnswerRe: Error: The resource cannot be found. Pin
ZurdoDev11-Sep-14 8:45
professionalZurdoDev11-Sep-14 8:45 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166711-Sep-14 9:03
Member 876166711-Sep-14 9:03 
AnswerRe: Error: The resource cannot be found. Pin
ZurdoDev11-Sep-14 9:06
professionalZurdoDev11-Sep-14 9:06 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166711-Sep-14 9:15
Member 876166711-Sep-14 9:15 
AnswerRe: Error: The resource cannot be found. Pin
ZurdoDev11-Sep-14 9:31
professionalZurdoDev11-Sep-14 9:31 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166711-Sep-14 9:33
Member 876166711-Sep-14 9:33 
SuggestionRe: Error: The resource cannot be found. Pin
Richard Deeming11-Sep-14 9:49
mveRichard Deeming11-Sep-14 9:49 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166711-Sep-14 10:16
Member 876166711-Sep-14 10:16 
GeneralRe: Error: The resource cannot be found. Pin
Richard Deeming12-Sep-14 1:37
mveRichard Deeming12-Sep-14 1:37 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166713-Sep-14 8:34
Member 876166713-Sep-14 8:34 
GeneralRe: Error: The resource cannot be found. Pin
Richard Deeming15-Sep-14 1:56
mveRichard Deeming15-Sep-14 1:56 
GeneralRe: Error: The resource cannot be found. Pin
Member 876166715-Sep-14 2:30
Member 876166715-Sep-14 2:30 
GeneralRe: Error: The resource cannot be found. Pin
ZurdoDev11-Sep-14 10:53
professionalZurdoDev11-Sep-14 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.