aspx应用程序在localhost上完美运行,但在在线服务器上却没有

时间:2016-09-21 21:18:01

标签: c# asp.net

花了几个小时后仍然找不到我的问题。我正在开发asp.net应用程序,其中我需要通过代码隐藏文件填充下拉控件的选项,它在我的本地主机上很好,但是当我在网站上检查它不起作用时。该页面显示没有任何选项的下拉框。

AspxFile

 <%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="About.aspx.cs" EnableEventValidation="true" Inherits="Acc.About" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    About
</h2>
<p>
    Put content here.
</p>
<form runat="server">
<div>
<asp:DropDownList id="modelItem" runat="server">
 <asp:ListItem>Select </asp:ListItem>
</asp:DropDownList>
 </div>
<div>
<asp:DropDownList id="ddl_update" runat="server">
  <asp:ListItem>Select </asp:ListItem>
</asp:DropDownList>
</div>
</form>

</asp:Content>

代码隐藏

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

namespace Acc
{
  public partial class About : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        AccDataContext db = new AccDataContext();
        var acc = from m in db.acs select m;
        foreach (var item in acc)
        {
            ListItem n = new ListItem();
            n.Text = item.title.Trim();
            n.Value = item.acode.Trim();
            modelItem.Items.Add(n);
            ddl_update.Items.Add(n);
        }
    }
    }
 }

DesignerFile

namespace Acc {


public partial class About {

    /// <summary>
    /// modelItem control.
    /// </summary>
    /// <remarks>
    /// Auto-generated field.
    /// To modify move field declaration from designer file to code-behind file.
    /// </remarks>
    protected global::System.Web.UI.WebControls.DropDownList modelItem;

    /// <summary>
    /// ddl_update control.
    /// </summary>
    /// <remarks>
    /// Auto-generated field.
    /// To modify move field declaration from designer file to code-behind file.
    /// </remarks>
    protected global::System.Web.UI.WebControls.DropDownList ddl_update;
}
}

0 个答案:

没有答案