Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This code works fine on localhost but not working on server


source:

XML
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Auto"  EnablePartialRendering="true">
        </asp:ScriptManager>
    <div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
    <div id="city" style="position:relative; float:left; width:450px">
    <div style="position:relative; margin-right:10px; margin-top:20px; float:left"><span style="float:left">State:</span><br />
        <asp:DropDownList  CssClass="dropdown" ID="st" style="vertical-align:middle"
            Font-Size="14px" Width="215px" Height="20px"  runat="server"
            AutoPostBack="True" onselectedindexchanged="st_SelectedIndexChanged"
            >
            <asp:ListItem>a</asp:ListItem>
            <asp:ListItem>b</asp:ListItem>
            <asp:ListItem>c</asp:ListItem>
            <asp:ListItem>d</asp:ListItem>
            <asp:ListItem>e</asp:ListItem>
        </asp:DropDownList></div><div style="position:relative; margin-top:20px; float:left"><span style="float:left">City:</span><br />
            <asp:DropDownList CssClass="dropdown" ID="cty" Font-Size="14px" Width="200px" Height="20px"
                runat="server"
                AutoPostBack="True"></asp:DropDownList></div>
    </div>
    </ContentTemplate>

        </asp:UpdatePanel>

    </div>
    </form>
</body>
</html>



c sharp:
C#
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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

    }
    protected void st_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (st.SelectedValue == "a")
        {
            cty.Items.Add("d");
        }
        if (st.SelectedValue == "b")
        {
            cty.Items.Add("c");
        }
        if (st.SelectedValue == "c")
        {
            cty.Items.Add("b");

        }
        if (st.SelectedValue == "d")
        {
            cty.Items.Add("a");
        }
    }
}
Posted
Comments
me.ajaykumar 8-Sep-13 6:28am    
while putting this to server, you are placing the updated ddls.
Right?
Dholakiya Ankit 9-Sep-13 3:03am    
wht error u are getting?

1 solution

Publish the project and host it,,,,
It will include all the needed dlls...
Also, check your dotnet version on server,,,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900