Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Button click not working

$
0
0

Hi Experts,

I'm having some trouble passing a variable when redirecting to a new page and I was hoping you would be able to help. 

I have a page in which a user needs to choose from a dropdown list of months that comes from a database, when they have chosen a month they need to click on a button control to redirect them to the required page based on the dropdownlist value they have chosen. At the moment, not matter what value they choose when the button is clicked nothing happens at all.

Any help here would be much appreciated as I'm a bit stuck!

I've attached my code to see if it helps at all.

Thanks,

Jonathan

Code Behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UsageStatsWebPortal.ScotiaBank
{
    public partial class ADReportChooseMonth : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var value = DropDownList1.SelectedValue;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue == "May")
            Response.Redirect("file://C:/inetpub/wwwroot/Consumption/Group Report_13-5-2013.html");
        }
    }
}
Asp.net Code:<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ADReportChooseMonth.aspx.cs" Inherits="UsageStatsWebPortal.ScotiaBank.ADReportChooseMonth" %><asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"><style type="text/css">
        .auto-style1 {
            text-decoration: underline;
        }</style></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"><hgroup class="title"><h1><%: Title %></h1><h2><br />
            Please choose a month to view the AD Group membership Report</h2></hgroup><p style="height: 10px">
            Please Enter a Month:            &nbsp;<asp:UpdatePanel ID="UpdatePanel2" runat="server"><ContentTemplate><asp:DropDownList ID="DropDownList1" runat="server" Height="19px" Width="156px" DataSourceID="Months" DataTextField="Month" DataValueField="Month" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true"><asp:ListItem>January</asp:ListItem><asp:ListItem>Febuary</asp:ListItem><asp:ListItem>March</asp:ListItem><asp:ListItem>April</asp:ListItem><asp:ListItem>May</asp:ListItem><asp:ListItem>June</asp:ListItem><asp:ListItem>July</asp:ListItem><asp:ListItem>August</asp:ListItem><asp:ListItem>September</asp:ListItem><asp:ListItem>October</asp:ListItem><asp:ListItem>November</asp:ListItem><asp:ListItem>December</asp:ListItem></asp:DropDownList><asp:SqlDataSource ID="Months" runat="server" ConnectionString="<%$ ConnectionStrings:Web_Portal_LiveConnectionString %>" SelectCommand="SELECT * FROM [Months]"></asp:SqlDataSource><br /><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Go" /><br /></ContentTemplate></asp:UpdatePanel></asp:Content>

Please let me know if any further information is needed.

Regards


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>