Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Pop up not showing when select option is pressed in the DrpProdType

$
0
0
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxDemo.aspx.cs" Inherits="WebApplication1.AjaxDemo" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>AjaxDemo</title><link href="Style/Site.css" rel="stylesheet" type="text/css" /><script src="Scripts/jquery-1.7.1.js"></script></head><body><form id="form1" runat="server"><div id="DemoDiv"><asp:ScriptManager ID="ScriptManagerDemo" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanelDemo" runat="server"><ContentTemplate><table id="TableDemo"><tr><th colspan="2">Admin Functionality</th><tr><td><asp:Label ID="lblType" runat="server" Text="Label">Select Product Type:</asp:Label></td><td><asp:DropDownList ID="DrpProdType" AutoPostBack="true" OnSelectedIndexChanged="DrpProdType_SelectedIndexChanged" runat="server"></asp:DropDownList></td></tr><tr><td><asp:Label ID="lblName" runat="server" Text="Label">Select Product Name:</asp:Label></td><td><asp:DropDownList ID="DrpProdName" AutoPostBack="true" runat="server"></asp:DropDownList></td></tr></tr><tr><td colspan="2"><asp:Button ID="btnSearch" runat="server" Text="Search" /></td></tr></table></ContentTemplate></asp:UpdatePanel></div></form></body></html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

                            

namespace WebApplication1
{
    public partial class AjaxDemo : System.Web.UI.Page
    {
        CommerceEntities cmd = new CommerceEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var country = from c in cmd.Categories select new { c.CategoryID, c.CategoryName };
                DrpProdType.DataSource = country.ToList();
                DrpProdType.DataValueField = "CategoryID";
                DrpProdType.DataTextField = "CategoryName";
                DrpProdType.DataBind();
                DrpProdType.Items.Insert(0, "Select");
            }

        }

        protected void DrpProdType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DrpProdType.SelectedValue != "Select")
            {
                int categoryID = Convert.ToInt32(DrpProdType.SelectedValue.ToString());
                var prodName = from c in cmd.Products
                               where c.CategoryID.Equals(categoryID)
                               select new { c.ProductID, c.ModelName };

                DrpProdName.DataSource = prodName.ToList();
                //ddlCity.Enabled = true;
                DrpProdName.DataValueField = "ProductID";
                DrpProdName.DataTextField = "ModelName";
                DrpProdName.DataBind();
            }
            else
            {
                string message = "Please select the Product type";
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
            }

        }

        
    }
}

The cascading concepts work fine as per my code.But when i am again selecting the select option of the first dropdown the pop up saying "Please select the Product type" is not firing.

please help 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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