Welcome to Dream.In.Code
Become an Expert!

Join 150,222 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,216 people online right now. Registration is fast and FREE... Join Now!




Client side scripting for content/master

 
Reply to this topicStart new topic

Client side scripting for content/master, avoiding a round trip to the server

ross_petersen
6 Dec, 2007 - 03:19 PM
Post #1

D.I.C Head
**

Joined: 6 Aug, 2005
Posts: 58



Thanked: 1 times
My Contributions
Hi folks

I have a aspx page that is linked to a master page.

The master page has three sections (top, LHS & footer) plus a content section.

The aspx page has a calendar control plus two buttons & two corresp text boxes. The buttons just read whatever date is selected and copies that to the corresp text box.

There are also some other controls as well on the page, but at this stage they don't do anything.

The problem I have is that every time one of the two buttons are clicked, it does what is intended, but it also causes a round trip to the server which is not what I want and is unnecessary at this point in time.

The dates that are written to the text boxes will eventually be used by the other unused controls that will extract info from a SQL DB based upon those dates.

Is there any way I can avoid a round trip to the server when the buttons are clicked?

Here is the markup for the aspx page:

CODE


<%@ Page Language="VB" MasterPageFile="~/CCFMaster1.master" AutoEventWireup="false" CodeFile="Sermons.aspx.vb" Inherits="Sermons" title="Sermons" %>
<asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">
    
    <script language="vbscript" runat="server">
        
        Sub SetDateFrom(ByVal sender As Object, ByVal e As EventArgs)
            Me.txtDateFrom.Text = Me.calChooseDate.SelectedDate.ToShortDateString
        End Sub
        
        Sub SetDateTo(ByVal sender As Object, ByVal e As EventArgs)
            Me.txtDateTo.Text = Me.calChooseDate.SelectedDate.ToShortDateString
        End Sub

    </script>
    
    If you have a look below, you will be able to see a Calendar and two buttons (From
    & To). All you have to do is pick a date on the Calendar, ...
    <br />
    <br />
    If you do that, then a drop down list box will be populated giving the dates of
    the aactual sermons.<br />
    <br />
    <asp:Calendar ID="calChooseDate" runat="server" BackColor="White" BorderColor="#3366CC"
        BorderWidth="1px" CellPadding="1" FirstDayOfWeek="Sunday" Font-Names="Verdana"
        Font-Size="8pt" ForeColor="#003399" Height="200px" Width="271px">
        <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
        <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
        <WeekendDayStyle BackColor="#CCCCFF" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
        <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
        <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
            Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
    </asp:Calendar>
    <br />
    <asp:Button ID="btnSetDateFrom" runat="server" Text="From" OnClick="SetDateFrom"/>
         
    <asp:TextBox ID="txtDateFrom" runat="server" Enabled="False"></asp:TextBox><br />
    <br />
    <asp:Button ID="btnSetDateTo" runat="server" Text="To" Width="44px" OnClick="SetDateTo"/>
         
    <asp:TextBox ID="txtDateTo" runat="server" Enabled="False"></asp:TextBox><br />
    <br />
    <asp:Button ID="btnShowSermonDates" runat="server" Text="Show Sermons" /><br />
    <br />
    <asp:DropDownList ID="ddlShowSermonDates" runat="server" AutoPostBack="True" Width="272px">
    </asp:DropDownList><br />
    <br />
    <asp:DataList ID="ShowSermonDetails" runat="server" BackColor="White" BorderColor="#E7E7FF"
        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingItemStyle BackColor="#F7F7F7" />
        <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
    </asp:DataList>
</asp:Content>



Kind regards

Ross



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:51AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month