我有一个名称空间Common.Param,在其中我创建了一组简单的静态字符串类,如下所示:
public class Url
{
public static string LoginPage;
public static string AdminPage;
public static string ProfilePage;
}
public class LoginDetails
{
public static string Username;
public static string Password;
}
我想用这样的xml文件填充这些字段
<
我在"Datasource.cs“文件中定义了一个类。在我的另一个asp.net文件"FineUIGrid.aspx.cs“中,我需要引用我在Datasource.cs中定义的类的方法。但是,当我引用该方法时,出现错误"the name 'class1‘is not exist in the current context“。如何解决这个问题?Datasource.cs代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.We
public sealed class UserLoginSingleton
{
UserLoginCollection _userLoginCol = new UserLoginCollection();
UserLoginSingleton()
{
}
public static UserLoginSingleton Instance
{
get
{
IDictionary items = HttpContext.Current.Items;
if (!
我有一个计算类文件,我正在做一些事情。我在aspx的.cs文件中创建了一个计算类的对象x,并在aspx中使用服务器标签调用它。现在,我正在获得该页面的点击量。该页面是为该类使用单个对象,还是为每个命中创建一个新对象?这是一个很好的编码实践吗?
calculation.cs
using system;
public calculation()
{
//some decelerations
}
public string getProduct()
{
return (A*B*C).toString();
}
page.aspx.cs
public calculation cal = new
在下面的代码段中,我从该类外部引用FILE_LOCATION,并且在执行流到该类以访问该常量之后,由于某种原因,执行将继续实例化单个实例,而不是继续返回进行常量调用的位置。
我的问题有两个部分,为什么会发生这种情况,我如何解决这个问题?我尝试创建两个分部类,一个仅用于常量,另一个用于其他所有内容,但执行仍然继续到另一个分部类来实例化单例。
public sealed class Foo
{
public static readonly string FILE_LOCATION = @"path\to\file";
// (singleton code mo
我正在使用带有C# WebMethod的aspx表单,但是在使用公共方法调用类时遇到了问题,我得到了以下错误消息:
非静态字段方法或属性需要对象引用。
下面是我的代码示例。
DB_Class
public int Cuenta(User us, int opcion)
{
string sql = "";
int res = 0;
switch (opcion)
{
//Insert
case 1:
sql = "query...";
bre
我正在尝试做简单的数据输入。我在App_Code文件夹中有用于输入的aspx文件和用于与数据实体交互的数据管理器文件。我有“静态”添加方法,但我不能添加“使用dataModel”行的模型文件,也不能在后面的代码中调用静态方法…
我遗漏了什么?
main.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using dataModel; // &l
我在web.config中添加了一个连接字符串。我做了一个字符串叫它的类-
namespace WebApplication1.Classes
{
public class Connections
{
public string DBConn =
ConfigurationManager.ConnectionStrings["HomeDB"].ConnectionString;
}
}
现在,在我的default.aspx.cs页面中,我想调用这个DBConn,以便在该页面中使用它。
namespace Web
在运行我的web应用程序后,我在浏览器中得到异常:The type initializer for 'my class' threw an exception.。由于这似乎是从视图(.aspx)生成的错误消息,因此我无法看到此错误来源的堆栈跟踪或任何日志。
我在网上读了一些东西,调试的一个解决方案是抛出一个TypeInitializationException,然后查看内部异常,找出哪里出了问题。当我不知道在哪里用try/catch包围代码时,我该怎么做呢?
我在aspx页面后面的代码中有一个方法,我需要从Javascript调用两个方法,我遇到的问题是我试图用一个Json请求和一个WebMethod来做这件事,但是这个方法必须是静态的,页面组件和其他方法不能通过这个方法访问。
我试着这样做:
javascript函数
function Func(Value) {
var conf=confirm('Sure? '+valor)
if (conf==true)
{
BlockAction();
}
}
function BlockA
我有三页: Login.aspx、Index.aspx和一个名为GlobalData.cs的C#类文件
Login.aspx背后的代码,用于从谷歌获取用户信息并显示在Index.aspx上
这是守则:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Rel
我有以下Globals.asax.cs文件。它在我的本地系统上工作得很好。但以下路由在服务器中不起作用
页面将被路由到
有谁能找到可能的问题。路由在我的本地sytem.But中工作,而不是在服务器上。我的Globals.asax.cs的内容如下所示。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
name
我的ASPX页面上有一个多视图,我想使用ActiveViewIndex设置它的JavaScript。为此,我使用了放置UpdatePanel控件的MultiView。我已经启用了EnablePageMethods="True" of ScriptManager。
每当我调用我要得到的Server方法时:
对象引用未设置为对象的实例
function CallScreens(id)
{
// var id,var type
// Call server side function
alert('Hello');
PageMeth
我是ASP.net的初学者,我想创建一个类文件,其中包含我的应用程序中常用的方法。就像这里的例子一样,它在login.aspx和registration.aspx页面中隐藏了某些ButtonLink。
但是当我打开这两个页面中的任何一个时,我都会得到这样的错误:
Object reference not set to an instance of an object.
下面是我的代码:
Helper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Syst
我有一个模块入口点init.js,如下所示
import $ from 'platform!jquery';
import angular from 'platform!angular';
import ngRoute from 'platform!angular-route';
import kendo from 'platform!kendo-ui';
import DemoModuleMain from './scripts/app.min';
export function render(containe
我有这个:
Public Class Foo
Private Shared ReadOnly machineName As String
Private Shared ReadOnly userName As String = Environment.UserName
Private Shared ReadOnly domainName As String
Private Shared ReadOnly events As New List(Of ManualResetEvent)()
Shared Sub New()
AddHand