or
<%@ Page Language="C#" EnableViewState="False" AutoEventWireup="True" CodeBehind="CustomLocalSettings.aspx.cs" Inherits="CableSolve.Web.Dashboard.Dialog.Windows.CustomLocalSettings" %><%@ Import Namespace="CableSolve.Web.Controllers.Managers" %><!DOCTYPE html><html lang="en"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" Runat="Server" /> <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="Server" DecoratedControls="All" /> <telerik:RadScriptBlock ID="RadScriptBlock1" Runat="Server" > <link rel="stylesheet" type="text/css" href="../../../Content/Dashboard/CustomLocalSettings.css?v=<%= VersionManager.GetApplicationVersion() %>" /> </telerik:RadScriptBlock> <telerik:RadScriptManager ID="RadScriptManager1" Runat="Server" EnablePageMethods="True"> <CompositeScript> <Scripts> <asp:ScriptReference Path="~/Scripts/Dashboard/CustomLocalSettings.js" /> <asp:ScriptReference Path="~/Scripts/Dashboard/SharedSettingsFunctionality.js" /> <asp:ScriptReference Path="~/Scripts/jquery-1.6.4.js" /> </Scripts> </CompositeScript> </telerik:RadScriptManager> <telerik:RadCodeBlock ID="RadCodeBlock1" Runat="server"> <script type="text/javascript"> var autoRefreshNumericTextBoxID = "<%= AutoRefreshNumericTextBox.ClientID %>"; var chartComboBoxID = "<%= ChartComboBox.ClientID %>"; var autoRefreshCheckBoxID = "<%= AutoRefreshCheckBox.ClientID %>"; </script> </telerik:RadCodeBlock> <div id="Content"> <fieldset id="RefreshProperties"> <legend>Refresh Settings</legend> <div id="RefreshArea"> <div id="RefreshLeftSide"> Auto-Refresh Enabled: <asp:CheckBox ID="AutoRefreshCheckBox" Runat="Server" /> </div> <div id="RefreshRightSide"> <telerik:RadNumericTextBox ID="AutoRefreshNumericTextBox" Runat="Server" Label="Auto-Refresh Interval (Minutes):" MaxValue="60" MinValue="1" ShowSpinButtons="True" Value="1" Width="225px" DataType="System.Int32"> <NumberFormat DecimalDigits="0" AllowRounding="False" /> </telerik:RadNumericTextBox> </div> </div> </fieldset> <fieldset id="ChartProperties"> <legend>Chart Properties</legend> <div id="ChartArea"> <telerik:RadComboBox ID="ChartComboBox" Runat="Server"> <Items> <telerik:RadComboBoxItem Runat="Server" Text="Bar Chart" Value="BarChart" /> <telerik:RadComboBoxItem Runat="Server" Text="Stacked Bar Chart" Value="StackedBarChart" /> </Items> </telerik:RadComboBox> </div> </fieldset> <div class="BottomButton"> <asp:UpdatePanel> <ContentTemplate> <telerik:RadButton ID="ApplySettings" Runat="Server" Text="Apply" OnClientClicked="CloseAndSave" /> </ContentTemplate> </asp:UpdatePanel> </div> </div> </form> </body></html>//SharedSettingsFunctionality.js//Contains functionality that all the dialog windows share in common. I found that I was maintaing a lot of code in multiple places unnecessarily.function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow;}function OnGetDockAttributesFailure(errors) { alert(errors);}function SetAutoRefreshState() { var autoRefreshNumericTextBox = $find(window.autoRefreshNumericTextBoxID); var wrapperElement = $get(autoRefreshNumericTextBox._wrapperElementID); var label = $(wrapperElement.getElementsByTagName("label")[0]); if ($('#' + window.autoRefreshCheckBoxID).is(':checked')) { autoRefreshNumericTextBox.enable(); label.addClass("LabelEnabled"); label.removeClass("LabelDisabled"); } else { autoRefreshNumericTextBox.disable(); label.addClass("LabelDisabled"); label.removeClass("LabelEnabled"); }}//CustomLocalSettings.jsfunction pageLoad() { var oWindow = GetRadWindow(); var dockID = oWindow.argument; if (dockID) { InitializeForm(dockID); } oWindow.argument = null;}function InitializeForm(dockID) { SetAutoRefreshState(); $('#' + window.autoRefreshCheckBoxID).click(SetAutoRefreshState); window.PageMethods.GetDockAttributes(dockID, OnGetDockAttributesSuccess, OnGetDockAttributesFailure);}//Pass the dialog data back to Dashboard.function CloseAndSave() { var oWindow = GetRadWindow(); var customAttributes = {}; customAttributes["RefreshEnabled"] = $('#' + window.autoRefreshCheckBoxID).is(':checked'); customAttributes["RefreshInterval"] = $find(window.autoRefreshNumericTextBoxID).get_value(); customAttributes["ChartType"] = $find(window.chartComboBoxID).get_value(); oWindow.argument = customAttributes; oWindow.close(); oWindow.argument = null; //Important because pageLoad gets called once more after oWindow closes.}function OnGetDockAttributesSuccess(result) { var dockData = $.parseJSON(result); //Change the initial loading state based on the dock's known settings. if (dockData["RefreshEnabled"]) { $('#' + window.autoRefreshCheckBoxID).attr('checked', true); var autoRefreshNumericTextBox = $find(window.autoRefreshNumericTextBoxID); autoRefreshNumericTextBox.set_value(dockData["RefreshInterval"]); autoRefreshNumericTextBox.enable(); var wrapperElement = $get(autoRefreshNumericTextBox._wrapperElementID); var label = $(wrapperElement.getElementsByTagName("label")[0]); label.addClass("LabelEnabled"); label.removeClass("LabelDisabled"); } $find(window.chartComboBoxID).findItemByValue(dockData["ChartType"]).select(); $('#Content').show(); GetRadWindow().autoSize();}//CustomLocalSettings CSSbody{ font-size: 12px; font-family: "segoe ui", arial, sans-serif; overflow: hidden; /*Leave this for auto-sizing behavior under IE*/ width: 403px;}.LabelEnabled,.riTextBox{ color: Black !important;}.LabelDisabled{ color: Gray !important;}.BottomButton{ padding-top: 7px; margin-left: 170px; padding-bottom: 7px;}#RefreshArea{ padding: 2px;}/*Leave this for IE8: Extends the fieldset to make it look proper.*/#ChartArea{ width: 378px;}#RefreshLeftSide{ float: left; margin-top: 3px;}#RefreshRightSide{ float: left; margin-left: 5px;}.rfdRoundedWrapper_fieldset{ display: block\9 !important;}#RefreshArea,#ChartArea{ overflow: auto\9; margin: 4px 5px 8px 5px\9;}._Telerik_IE9 #RefreshArea,._Telerik_IE9 #ChartArea{ margin: 0px;}#Content{ display: none;}EnableRandomOrder="true" and
PauseOnMouseOver
="false"
as below. In the attached image below, Next Item to be shown is Disease Analytics when i click on the ControlButtons in right side. How can i access the index/ item itself on click of the control button in javacript. I need the next item/previous item to be shown when i click on the controlbuttons in javascript only as I've to update the description of the selected item using ajaxmanager and also on random click on the radrotator item(which is an image) corresponding description has to be shown.
<ControlButtons OnClientButtonClick="OnClientButtonClick" />
function OnClientButtonClick(sender, args) { var objArgs; debugger; if (typeof sender._nextItemIndex === "undefined") objArgs = 0; else { if (sender._nextItemIndex == null) objArgs = 0; else objArgs = sender._nextItemIndex; } //sender.get_currentItem().get_index(); $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(objArgs);}<telerik:RadAjaxManager ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest" runat="server" DefaultLoadingPanelID="LoadingPanel1"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="chkRotationType"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="radRotProducts" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="detailsPanel" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager><telerik:RadAjaxPanel ID="AjaxPanel1" CssClass="rotNoButtonsBack" runat="server" LoadingPanelID="LoadingPanel1"> <div class="mainDiv"> <div class="rotatorBackground"> <%-- ItemWidth and ItemHeight include 2x5(pixels) margin and 1x2(pixels) border --%> <telerik:RadRotator ID="radRotProducts" RotatorType="CarouselButtons" runat="server" EnableRandomOrder="true" PauseOnMouseOver="false" OnClientItemClicked="OnClientItemClicked" Width="800px" Height="400px" CssClass="rotatorCarouselStyle" ItemHeight="200" FrameDuration="2000" ItemWidth="300" ScrollDuration="500"> <ItemTemplate> <asp:Image runat="server" ID="imgProduct" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"Image")%>' CssClass="RotatorItem" /> </ItemTemplate> <ControlButtons OnClientButtonClick="OnClientButtonClick" /> </telerik:RadRotator> </div> </div> </telerik:RadAjaxPanel><%@ Page Title="Campaign Finance - Create New Petition" Language="C#" MasterPageFile="~/Masters/EPSDev2.master" AutoEventWireup="true" CodeFile="NewPetition.aspx.cs" Inherits="NewPetition" %><asp:Content ID="Content1" ContentPlaceHolderID="PageHeadContent" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="PageContent" Runat="Server"> <div style="width: 100%;"> <div style="float: left; background-color: White; padding: 10px;"> <table cellpadding="20" cellspacing="0" border="0" > <tr> <td width="5%"> </td> <td align="center" width="90%" nowrap="nowrap"> <table cellpadding="0" cellspacing="15" id="TABLE1" > <tr> <td colspan="2" align="center" > <h2> <asp:Label ID="VoterAuthenticationLabel" runat="server" Text="Create New Petition"></asp:Label> </h2> </td> </tr> <tr> <td colspan="2" align="center" style="font-weight: normal; height: 12px;"> <asp:Label ID="InfoLabel" runat="server" Text="(Please enter the information requested below and then click on the SUBMIT button)"></asp:Label> </td> </tr> <tr> <td colspan="2" align="center" style="font-weight: normal; height: 12px;"> </td> </tr> <tr> <td colspan="2" align="left" style="font-weight: normal; height: 12px;"> <asp:Label ID="Label6" runat="server" Font-Bold="true" Text="CANDIDATE INFORMATION:"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:Label ID="CycleLabel" runat="server" Text="Cycle:"></asp:Label> </td> <td align="left"> <telerik:RadComboBox ID="ElectionCycleList" runat="server" TabIndex="1" EnableEmbeddedSkins="true" Skin="Default" OnClientSelectedIndexChanging="LoadPoliticalRaceList" > </telerik:RadComboBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="ElectionCycleListReqd" ControlToValidate="ElectionCycleList" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must select an Election Cycle from the list" ForeColor="Red"> </asp:RequiredFieldValidator> <asp:CustomValidator ID="CustomValidator5" runat="server" ControlToValidate="ElectionCycleList" ClientValidationFunction="validateCombo5" ErrorMessage="<br>You must select an Election Cycle from the list" ValidationGroup="DEForm" Display="Dynamic" ForeColor="Red" > </asp:CustomValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label14" runat="server" Text="Election:"></asp:Label> </td> <td align="left"> <telerik:RadComboBox ID="ElectionList" runat="server" TabIndex="1" OnClientItemsRequested="SearchItemsLoaded" OnItemsRequested="ElectionList_ItemsRequested" EnableEmbeddedSkins="true" Skin="Default" EnableViewState="true" ViewStateMode="Enabled" > </telerik:RadComboBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="ElectionListReqd" ControlToValidate="ElectionList" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must select an Election from the list." ForeColor="Red"> </asp:RequiredFieldValidator> <asp:CustomValidator ID="CustomValidator4" runat="server" ControlToValidate="ElectionList" ClientValidationFunction="validateCombo4" ErrorMessage="<br>You must select an Election from the list" ValidationGroup="DEForm" Display="Dynamic" ForeColor="Red" > </asp:CustomValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label1" runat="server" Text="Political Race:"></asp:Label> </td> <td align="left"> <telerik:RadComboBox ID="PoliticalRaceList" Width="250px" runat="server" TabIndex="2" OnClientItemsRequested="SearchItemsLoaded" OnItemsRequested="PoliticalRaceList_ItemsRequested" EnableEmbeddedSkins="true" Skin="Default" > </telerik:RadComboBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="PoliticalRaceListReqd" ControlToValidate="PoliticalRaceList" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must select a Political Race from the list" ForeColor="Red"> </asp:RequiredFieldValidator> <asp:CustomValidator ID="CustomValidator3" runat="server" ControlToValidate="PoliticalRaceList" ClientValidationFunction="validateCombo3" ErrorMessage="<br>You must select a Political Race from the list" ValidationGroup="DEForm" Display="Dynamic" ForeColor="Red" > </asp:CustomValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label12" runat="server" Text="Political Party:"></asp:Label> </td> <td align="left"> <telerik:RadComboBox ID="PoliticalPartyList" runat="server" TabIndex="3" EnableEmbeddedSkins="true" Skin="Default"> </telerik:RadComboBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="PoliticalPartyList" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must select a Political Party from the list" ForeColor="Red"> </asp:RequiredFieldValidator> <asp:CustomValidator ID="CustomValidator2" runat="server" ControlToValidate="PoliticalPartyList" ClientValidationFunction="validateCombo2" ErrorMessage="<br>You must select a Political Party from the list" ValidationGroup="DEForm" Display="Dynamic" ForeColor="Red" > </asp:CustomValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label2" runat="server" Text="Name:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="CandidateName" runat="server" MaxLength="50" Width="200px" TabIndex="4" EnableEmbeddedSkins="true" Skin="Default" ></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="CandidateNameReqd" ControlToValidate="CandidateName" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Candidate's Name" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label3" runat="server" Text="Address:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="CandidateAddress1" runat="server" MaxLength="50" Width="200px" TabIndex="5" EnableEmbeddedSkins="true" Skin="Default"></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="CandidateAddress1Reqd" ControlToValidate="CandidateAddress1" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Candidate's Address" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label13" runat="server" Text="Address 2:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="CandidateAddress2" runat="server" MaxLength="50" Width="200px" TabIndex="5" EnableEmbeddedSkins="true" Skin="Default" ></telerik:RadTextBox> <br /> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label4" runat="server" Text="City, State, Zip Code:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="CandidateCity" runat="server" MaxLength="50" Width="200px" TabIndex="6" EnableEmbeddedSkins="true" Skin="Default"></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <telerik:RadTextBox ID="CandidateState" runat="server" MaxLength="2" Width="30px" TabIndex="7" Text="AZ" EnableEmbeddedSkins="true" Skin="Default"></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <telerik:RadTextBox ID="CandidateZipCode" runat="server" TabIndex="8" MaxLength="10" Width="75px" EnableEmbeddedSkins="true" Skin="Default"></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="CandidateCityReqd" ControlToValidate="CandidateCity" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Candidate's City" ForeColor="Red"></asp:RequiredFieldValidator> <asp:RequiredFieldValidator ID="CandidateStateReqd" ControlToValidate="CandidateState" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Candidate's State" ForeColor="Red"></asp:RequiredFieldValidator> <asp:RequiredFieldValidator ID="CandidateZipCodeReqd" ControlToValidate="CandidateZipCode" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Candidate's Zip Code" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label5" runat="server" Text="County:"></asp:Label> </td> <td align="left"> <telerik:RadComboBox ID="CandidateCountyList" runat="server" TabIndex="9" EnableEmbeddedSkins="true" Skin="Default"> </telerik:RadComboBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="CandidateCountyListReqd" ControlToValidate="CandidateCountyList" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must select the Candidate's County from the list" ForeColor="Red"> </asp:RequiredFieldValidator> <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="CandidateCountyList" ClientValidationFunction="validateCombo1" ErrorMessage="<br>You must select the Candidate's County" ValidationGroup="DEForm" Display="Dynamic" ForeColor="Red" > </asp:CustomValidator> </td> </tr> <tr> <td colspan="2" align="center" style="font-weight: normal; height: 12px;"> </td> </tr> <tr> <td colspan="2" align="left" style="font-weight: normal; height: 12px;"> <asp:Label ID="Label7" runat="server" Font-Bold="true" Text="CONTACT INFORMATION:"></asp:Label> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label8" runat="server" Text="Name:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="ContactName" runat="server" MaxLength="50" Width="200px" TabIndex="10" EnableEmbeddedSkins="true" Skin="Default"></telerik:RadTextBox> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> <asp:RequiredFieldValidator ID="ContactNameReqd" ControlToValidate="ContactName" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>You must enter the Contact's Name" ForeColor="Red"></asp:RequiredFieldValidator> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label9" runat="server" Text="Telephone:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="ContactPhone" runat="server" MaxLength="25" Width="100px" TabIndex="11" EnableEmbeddedSkins="true" Skin="Default" ></telerik:RadTextBox><br /> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label10" runat="server" Text="Email Address:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="ContactEmailAddress" runat="server" MaxLength="256" Width="300px" TabIndex="12" EnableEmbeddedSkins="true" Skin="Default" ></telerik:RadTextBox><br /> </td> </tr> <tr> <td align="left"> <asp:Label ID="Label11" runat="server" Text="Web Site URL:"></asp:Label> </td> <td align="left"> <telerik:RadTextBox ID="ContactWebSiteURL" runat="server" MaxLength="50" Width="200px" TabIndex="13" EnableEmbeddedSkins="true" Skin="Default" ></telerik:RadTextBox> <asp:CustomValidator ID="ContactWebSiteURLCustom" ControlToValidate="ContactWebSiteURL" ValidationGroup="DEForm" Display="Dynamic" runat="server" ErrorMessage="<br>If provided, the web site URL must be present on the Internet." ForeColor="Red" OnServerValidate="ValidateURL" ></asp:CustomValidator> </td> </tr> <tr> <td colspan="2" align="center" style="font-weight: normal; height: 12px;"> <asp:Button ID="CreateButton" runat="server" Text="Create Petition" TabIndex="15" ValidationGroup="DEForm" onclick="CreateButton_Click" /> <asp:Button ID="CancelButton" runat="server" Text="Cancel Petition" TabIndex="16" onclick="CancelButton_Click" /> </td> </tr> <tr> <td colspan="2" align="center" style="font-weight: normal; height: 12px;"> <img alt="Required field" src="<%=ResolveUrl("images/required2.gif")%>" /> - <asp:Label ID="IndicatesRequiredLabel" runat="server" Text="Indicates a required field"></asp:Label> <br /> <asp:Label ID="StatusLabel" ForeColor="Red" runat="server" /> <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="DEForm" DisplayMode="List" ForeColor="Red" ShowSummary="False" runat="server" /> </td> </tr> </table> </td> <td width="5%"> </td> </tr> </table> </div> <div class="clear"> </div> </div> <script type="text/javascript"> function LoadPoliticalRaceList(combo, eventArqs) { var searchcycleCombo = $find("<%=ElectionCycleList.ClientID%>"); var searchraceCombo = $find("<%=PoliticalRaceList.ClientID%>"); var searchelectionCombo = $find("<%=ElectionList.ClientID%>"); var item = eventArqs.get_item(); searchraceCombo.set_text("Loading..."); // if a cycle is selected if (item.get_index() > 0) { // this will fire the ItemsRequested event of the // property type combobox passing the transaction type as a parameter searchraceCombo.requestItems(item.get_value(), false); } else { // the -Select a cycle- item was chosen searchraceCombo.set_text(" "); searchraceCombo.clearItems(); } var item = eventArqs.get_item(); searchelectionCombo.set_text("Loading..."); // if a cycle is selected if (item.get_index() > 0) { // this will fire the ItemsRequested event of the // property type combobox passing the transaction type as a parameter searchelectionCombo.requestItems(item.get_value(), false); } else { // the -Select a cycle- item was chosen searchelectionCombo.set_text(" "); searchelectionCombo.clearItems(); } } function SearchItemsLoaded(combo, eventArqs) { if (combo.get_items().get_count() > 0) { // pre-select the first item combo.set_text(combo.get_items().getItem(0).get_text()); combo.get_items().getItem(0).highlight(); } } function validateCombo1(source, args) { args.IsValid = false; var combo = $find("<%= CandidateCountyList.ClientID %>"); var text = combo.get_text(); if (text.length < 1) { args.IsValid = false; } else { var node = combo.findItemByText(text); if (node) { var value = node.get_value(); if (value.length > 0) { args.IsValid = true; } } else { args.IsValid = false; } } } function validateCombo2(source, args) { args.IsValid = false; var combo = $find("<%= PoliticalPartyList.ClientID %>"); var text = combo.get_text(); if (text.length < 1) { args.IsValid = false; } else { var node = combo.findItemByText(text); if (node) { var value = node.get_value(); if (value.length > 0) { args.IsValid = true; } } else { args.IsValid = false; } } } function validateCombo3(source, args) { args.IsValid = false; var combo = $find("<%= PoliticalRaceList.ClientID %>"); var text = combo.get_text(); if (text.length < 1) { args.IsValid = false; } else { var node = combo.findItemByText(text); if (node) { var value = node.get_value(); if (value.length > 0) { args.IsValid = true; } } else { args.IsValid = false; } } } function validateCombo4(source, args) { args.IsValid = false; var combo = $find("<%= ElectionList.ClientID %>"); var text = combo.get_text(); if (text.length < 1) { args.IsValid = false; } else { var node = combo.findItemByText(text); if (node) { var value = node.get_value(); if (value.length > 0) { args.IsValid = true; } } else { args.IsValid = false; } } } function validateCombo5(source, args) { args.IsValid = false; var combo = $find("<%= ElectionCycleList.ClientID %>"); var text = combo.get_text(); if (text.length < 1) { args.IsValid = false; } else { var node = combo.findItemByText(text); if (node) { var value = node.get_value(); if (value.length > 0) { args.IsValid = true; } } else { args.IsValid = false; } } } </script></asp:Content>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Web.UI;using System.Data.SqlClient;using System.Configuration;using System.Data;using System.Text;using System.Net;using System.IO;public partial class NewPetition : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { // The purpose of this page is to initiate the creation of a new petition. // We need to check for the presence of the query string member '19' and if its value is 'edt'. // If yes to both of these questions, then the user has already entered the data for a new petition but // clicked the edit button on the next confirmation page. // If the answer to either of these is no, then we will give the user an empty page to enter data into // except for the three (3) combo boxes --the Election Cycle, Political Party and the County combo boxes. // The Political Race combo box will be dynamically loaded after the user selects an Election Cycle. if (!Page.IsPostBack) { // If this is the new petition data coming back for edit from the confirmation page, // then load the screen controls up with the data if (Request.QueryString["19"] == "edt") { this.CandidateName.Text = Request.QueryString["4"]; this.CandidateAddress1.Text = Request.QueryString["5"]; this.CandidateAddress2.Text = Request.QueryString["6"]; this.CandidateCity.Text = Request.QueryString["7"]; this.CandidateState.Text = Request.QueryString["8"]; this.CandidateZipCode.Text = Request.QueryString["9"]; this.ContactName.Text = Request.QueryString["11"]; this.ContactPhone.Text = Request.QueryString["12"]; this.ContactEmailAddress.Text = Request.QueryString["13"]; this.ContactWebSiteURL.Text = Request.QueryString["14"]; LoadElectionCycleList2(this.ElectionCycleList, Request.QueryString["1"]); LoadPoliticalRaceList2(this.PoliticalRaceList, Request.QueryString["2"]); LoadPoliticalPartyList2(this.PoliticalPartyList, Request.QueryString["3"]); LoadCountyList2(this.CandidateCountyList, Request.QueryString["10"]); LoadElectionList2(this.ElectionList, Request.QueryString["20"]); } else // This is a new page request so only load the combo boxes, // there is nothing else to do { this.CandidateName.Text = Convert.ToString(Session["CandidateFullName"]); LoadElectionCycleList(this.ElectionCycleList); LoadPoliticalPartyList(this.PoliticalPartyList); LoadCountyList(this.CandidateCountyList); } } else { string sCB1 = Convert.ToString(this.ElectionList.SelectedValue); string sCB2 = Convert.ToString(this.PoliticalRaceList.SelectedValue); string a = "abc"; } } protected void ElectionList_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) { // The user-selected Election Cycle value is passed to us so can correctly populate this list LoadElectionList(this.ElectionList, e.Text); } private void LoadElectionList2(RadComboBox combobox, string cbval) { LoadElectionList(this.ElectionList, Request.QueryString["1"]); this.ElectionList.SelectedValue = cbval; } private void LoadElectionCycleList2(RadComboBox combobox, string cbval) { LoadElectionCycleList(this.ElectionCycleList); this.ElectionCycleList.SelectedValue = cbval; } private void LoadPoliticalRaceList2(RadComboBox combobox, string cbval) { LoadPoliticalRaceList(this.PoliticalRaceList, Request.QueryString["1"]); //LoadPoliticalRaceList(this.PoliticalRaceList, Request.QueryString["15"]); this.PoliticalRaceList.SelectedValue = cbval; } private void LoadPoliticalPartyList2(RadComboBox combobox, string cbval) { LoadPoliticalPartyList(this.PoliticalPartyList); this.PoliticalPartyList.SelectedValue = cbval; } private void LoadCountyList2(RadComboBox combobox, string cbval) { LoadCountyList(this.CandidateCountyList); this.CandidateCountyList.SelectedValue = cbval; } private void LoadElectionList(RadComboBox combobox, string electioncycleno) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString); SqlDataAdapter adapter = new SqlDataAdapter("SELECT TOP (100) PERCENT ElectionName, ElectionId, CycleId, ElectionDate FROM dbo.Elections WHERE (CycleId = " + electioncycleno + ") ORDER BY ElectionDate", connection); DataTable dt = new DataTable(); adapter.Fill(dt); combobox.DataTextField = "ElectionName"; combobox.DataValueField = "ElectionId"; combobox.DataSource = dt; combobox.DataBind(); // Insert the first item. combobox.Items.Insert(0, new RadComboBoxItem("- Select an election -")); } protected void ElectList_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) { // The user-selected Election Cycle value is passed to us so can correctly populate this list LoadElectionList(this.ElectionList, e.Text); } private void LoadElectionCycleList(RadComboBox combobox) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString); SqlDataAdapter adapter = new SqlDataAdapter("SELECT CycleId, CycleName FROM Cycles WHERE EndDate > GETDATE() ORDER By CycleName", connection); DataTable dt = new DataTable(); adapter.Fill(dt); combobox.DataTextField = "CycleName"; combobox.DataValueField = "CycleId"; combobox.DataSource = dt; combobox.DataBind(); // Insert the first item. combobox.Items.Insert(0, new RadComboBoxItem("- Select a cycle -")); } protected void PoliticalRaceList_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) { // The user-selected Election Cycle value is passed to us so can correctly populate this list LoadPoliticalRaceList(this.PoliticalRaceList, e.Text); } private void LoadPoliticalRaceList(RadComboBox combobox, string electioncycleno) { if (electioncycleno.Length > 0) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString); string sqlcode = "SELECT Cycles.CycleId, Cycles.CycleName, Cycles.BeginDate, Races.RaceId, Offices.OfficeId, Offices.OfficeDescription FROM Cycles INNER JOIN Races ON Cycles.CycleId = Races.CycleId INNER JOIN Offices ON Races.OfficeId = Offices.OfficeId WHERE Cycles.CycleId = " + electioncycleno + " ORDER BY OfficeDescription"; SqlDataAdapter adapter = new SqlDataAdapter(sqlcode, connection); DataTable dt = new DataTable(); adapter.Fill(dt); combobox.DataTextField = "OfficeDescription"; combobox.DataValueField = "RaceId"; combobox.DataSource = dt; combobox.DataBind(); // Insert the first item. combobox.Items.Insert(0, new RadComboBoxItem("- Select a race")); } } private void LoadPoliticalPartyList(RadComboBox combobox) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString); SqlDataAdapter adapter = new SqlDataAdapter("SELECT PartyId, PartyName, DisplayOrder FROM Parties ORDER By DisplayOrder", connection); DataTable dt = new DataTable(); adapter.Fill(dt); combobox.DataTextField = "PartyName"; combobox.DataValueField = "PartyId"; combobox.DataSource = dt; combobox.DataBind(); // Insert the first item. combobox.Items.Insert(0, new RadComboBoxItem("- Select a party -")); } private void LoadCountyList(RadComboBox combobox) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString); SqlDataAdapter adapter = new SqlDataAdapter("SELECT CountyId, CountyName FROM Counties ORDER By CountyName", connection); DataTable dt = new DataTable(); adapter.Fill(dt); combobox.DataTextField = "CountyName"; combobox.DataValueField = "CountyId"; combobox.DataSource = dt; combobox.DataBind(); // Insert the first item. combobox.Items.Insert(0, new RadComboBoxItem("- Select a county -")); } protected void CreateButton_Click(object sender, EventArgs e) { // Create the new petition if the input validates if (Page.IsValid) { // If the data entered is valid, then send the user (and the data) to the Confirmation page to make // certain that they actually do want to create the new petition before doing it, otherwise .NET will // send them back to correct the data string sQueryString = ""; sQueryString += "1=" + this.ElectionCycleList.SelectedValue; sQueryString += "&2=" + this.PoliticalRaceList.SelectedValue; sQueryString += "&3=" + this.PoliticalPartyList.SelectedValue; sQueryString += "&4=" + this.CandidateName.Text; sQueryString += "&5=" + this.CandidateAddress1.Text; sQueryString += "&6=" + this.CandidateAddress2.Text; sQueryString += "&7=" + this.CandidateCity.Text; sQueryString += "&8=" + this.CandidateState.Text; sQueryString += "&9=" + this.CandidateZipCode.Text; sQueryString += "&10=" + this.CandidateCountyList.SelectedValue; sQueryString += "&11=" + this.ContactName.Text; sQueryString += "&12=" + this.ContactPhone.Text; sQueryString += "&13=" + this.ContactEmailAddress.Text; sQueryString += "&14=" + this.ContactWebSiteURL.Text; sQueryString += "&15=" + this.ElectionCycleList.Text; sQueryString += "&16=" + this.PoliticalRaceList.Text; sQueryString += "&17=" + this.PoliticalPartyList.Text; sQueryString += "&18=" + this.CandidateCountyList.Text; sQueryString += "&20=" + this.ElectionList.SelectedValue; sQueryString += "&21=" + this.ElectionList.Text; Response.Redirect("NewPetitionConf.aspx?" + sQueryString); } } protected void CancelButton_Click(object sender, EventArgs e) { // If the user cancels the new petition, then we need to back to MyeDocs.aspx Response.Redirect("MyEDocs.aspx"); } protected void ValidateURL(object source, ServerValidateEventArgs args) { args.IsValid = true; WebRequest webRequest = null; WebResponse webResponse = null; try { webRequest = WebRequest.Create(this.ContactWebSiteURL.Text); webResponse = webRequest.GetResponse(); } catch (UriFormatException ex) { ContactWebSiteURLCustom.ErrorMessage = ex.Message; args.IsValid = false; } catch (WebException ex) { ContactWebSiteURLCustom.ErrorMessage = ex.Message; args.IsValid = false; if (ex.Response != null && ex.Response.Headers != null) { ContactWebSiteURLCustom.ErrorMessage = ex.Message; //+ " - Web Exception - " + ex.Response.Headers.ToString(); args.IsValid = false; } ContactWebSiteURLCustom.ErrorMessage = ex.Message; //+ " - \nStack Trace Error - " + ex.ToString(); args.IsValid = false; } catch (Exception ex) { ContactWebSiteURLCustom.ErrorMessage = ex.Message; //+ " - \nStack Trace Error - " + ex.ToString(); args.IsValid = false; } finally { if (webResponse != null) { webResponse.Close(); } } Boolean bFlag = args.IsValid; }}