26 Aralık 2012 Çarşamba

easy login mechanism for demo purposes

When you need to prepare a quick demo for a few users and you have not implemented your login mechanism yet, you can easily add forms authentication to you asp.net web application.

a simple login form (.aspx file)
<p>
        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
    </p>
    <p>
        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
        <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
    </p>

server side (aspx.cs file):
         protected void Page_Load(object sender, EventArgs e)
        {
            if (FormsAuthentication.Authenticate(this.UserName.Text, this.Password.Text))
            {
                FormsAuthentication.RedirectFromLoginPage(this.UserName.Text, true);
            }
        }

add the following lines to web.config file:
     <authentication mode="Forms">
      <forms loginUrl="~/menu/Login.aspx"  defaultUrl="~/menu/MenuMyApp.aspx" timeout="2880" cookieless="AutoDetect">
        <credentials passwordFormat="Clear">
          <user name="demo1" password="1"/>
          <user name="demo2" password="2"/>
        </credentials>
      </forms>
    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>

Your demo app is secure now.. Demo users can only login with the credentials specified.



15 Aralık 2012 Cumartesi

how to telerik:RadMenu show path


In order to view the selected path from your telerik RadMenu as in the picture below, you can use the following code:







aspx code:


<telerik:RadSiteMap ID="BreadCrumbSiteMap" runat="server" DataTextField="Text" DataNavigateUrlField="NavigateUrl">
        <DefaultLevelSettings ListLayout-RepeatDirection="Horizontal" SeparatorText="/" Layout="Flow" />
</telerik:RadSiteMap>



csharp code:


      protected void Page_Load(object sender, EventArgs e)
        {
            RadMenuItem currentItem = RadMenu.FindItemByUrl(Request.Url.PathAndQuery);
            if (currentItem != null)
            {
                currentItem.HighlightPath();
                DataBindBreadCrumbSiteMap(currentItem);
            }
            else
                RadMenu.Items[0].HighlightPath();
        }

        private void DataBindBreadCrumbSiteMap(RadMenuItem currentItem)
        {
            List breadCrumbPath = new List();
            while (currentItem != null)
            {
                breadCrumbPath.Insert(0, currentItem);
                currentItem = currentItem.Owner as RadMenuItem;
            }
            BreadCrumbSiteMap.DataSource = breadCrumbPath;
            BreadCrumbSiteMap.DataBind();
        }



The solution is from here: http://demos.telerik.com/aspnet-ajax/menu/examples/programming/showpath/defaultcs.aspx?Page=Blogs

13 Aralık 2012 Perşembe

using Telerik Scheduler to view weekly lesson plan


In this post, i present the code that configures Telerik radscheduler to view a weekly lesson plan. In order to do this, the selected date attribute should be a month starting at Monday (which is the first week day in the scheduler.)
.aspx code (actually i use it as a user control )
<telerik:RadScheduler runat="server" ID="RadScheduler" Width="750px" SelectedView="WeekView"
    TimeZoneOffset="00:00:00" SelectedDate="2013-04-01" DayStartTime="07:00:00" DayEndTime="23:59:00"
     ReadOnly="true"
     DataEndField="End" 
     DataKeyField="DersProgramiID" DataStartField="Start" DataSubjectField="DersItem" 
     AllowDelete="False" AllowEdit="False" AllowInsert="False" 
     DayView-DayStartTime="07:00:00" DayView-DayEndTime="23:59:00" LastDayOfWeek="Sunday" 
     WeekView-DayEndTime="23:59:00" WeekView-DayStartTime="07:00:00" WeekView-WorkDayEndTime="23:59:00" 
     WeekView-WorkDayStartTime="07:00:00" WorkDayEndTime="23:59:00" WorkDayStartTime="07:00:00" FirstDayOfWeek="Monday" 
     Height="900px" ShowNavigationPane="True" ShowAllDayRow="False" ShowHeader="False" ShowFullTime="False" ShowFooter="False" HoursPanelTimeFormat="HH:mm">
    <TimelineView UserSelectable="false" ShowDateHeaders="false"></TimelineView>
    <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
    <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
</telerik:RadScheduler>

csharp code to fill the scheduler:
 public void fill(List list)
 {
      this.RadScheduler.DataSource = list;
      this.RadScheduler.DataBind();

  }

The weekly lesson plan is as follows: