Tag: asp.net

调用按钮serveride的click事件

如何在代码隐藏中单击或加载按钮的click()事件? 我已经试过了 btn.Click(); 但这会给出错误。 我正在使用ASP.NET

使用参数动态加载用户控件

我已经创建了一个用户控件。 public partial class Controls_pageGeneral : System.Web.UI.UserControl { private int pageId; private int itemIndex; public int PageId { get { return pageId; } set { pageId = value; } } public int ItemIndex { get { return itemIndex; } set { itemIndex = value; } } protected void Page_Load(object sender, EventArgs e) { // something […]

如何使用Owin中间件拦截404

背景 首先让我解释一下背景。 我正在研究一个项目,该项目试图将使用通过IIS上托管的OWIN配置的Web API的后端服务器结合起来,但未来可能还有其他OWIN支持的主机 – 使用AngularJS的前端。 AngularJS前端完全是静态内容。 我完全避免服务器端技术,如MVC / Razor,WebForms,Bundles,任何与前端及其使用的资产有关的技术,而是推迟使用Node.js,Grunt / Gulp等最新最好的技术。处理CSS编译,捆绑,缩小等等。由于我不会进入这里的原因,我将前端和服务器项目保存在同一项目中的不同位置(而不是直接将它们全部放在Host项目中(参见raw下图)。 MyProject.sln server MyProject.Host MyProject.Host.csproj Startup.cs (etc.) frontend MyProjectApp app.js index.html MyProjectApp.njproj (etc.) 所以就前端而言,我需要做的就是让我的主机服务我的静态内容。 在Express.js中,这是微不足道的。 使用OWIN,我能够使用Microsoft.Owin.StaticFiles中间件轻松地完成此操作,并且它运行良好(非常灵活)。 这是我的OwinStartup配置: string dir = AppDomain.CurrentDomain.RelativeSearchPath; // get executing path string contentPath = Path.GetFullPath(Path.Combine(dir, @”../../../frontend/MyProjectApp”)); // resolve nearby frontend project directory app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true, FileSystem = […]

XML序列化,编码

using System; public class clsPerson { public string FirstName; public string MI; public string LastName; } class class1 { static void Main(string[] args) { clsPerson p=new clsPerson(); p.FirstName = “Jeff”; p.MI = “A”; p.LastName = “Price”; System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType()); x.Serialize(Console.Out, p); Console.WriteLine(); Console.ReadLine(); } } 取自http://support.microsoft.com/kb/815813 1) System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType()); 这条线做什么? […]

在Switch语句中使用.StartsWith?

我正在处理一个Switch语句,并且有两个条件需要查看值是否以特定值开头。 Switch语句就是这样的。 错误说“不能将bool类型转换为字符串”。 任何人都知道我是否可以在Switch中使用StartsWith或者我是否需要使用If … Else语句? switch(subArea) { case “4100”: case “4101”: case “4102”: case “4200”: return “ABC”; case “600A”: return “XWZ”; case subArea.StartsWith(“3*”): case subArea.StartsWith(“03*”): return “123”; default: return “ABCXYZ123”; }

应用池身份与假冒身份?

我发现只有一个与此相关的post,但它没有回答这个问题。 我很想知道在web.config中设置模拟用户与在IIS中设置应用程序池标识之间的区别的链接或解释。 他们似乎是独立的,并且对细节差异感到困惑。 谢谢。

如何在asp.net上显示MessageBox?

如果我需要在我的ASP.NET WebForm上显示MessageBox,该怎么做? 我试试: Messagebox.show(“dd”); 但它不起作用。

最佳URLvalidation

我使用下面的代码来检查URLvalidation: public static bool CheckURLValid(string strURL) { Uri uriResult; return Uri.TryCreate(strURL, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp; } 下面的结果应该显示为true ,但不知何故它有自己的模式来validationurl: false :google.com 是的 : http : //www.google.com false : https : //www.google.com.my/webhp?sourceid = chrome-instant&ion = 1&espv = 2&es_th = 1&ie = UTF-8’newwindow = 1&q = check%20if%20valid%20url%20c%23 是的 : https : //stackoverflow.com/questions/ask 即时通讯使用c#,如何增强此检查urlvalidation更准确?

如何在选定的索引更改属性上找到gridview的datakey值?

我的gridview是这样的,但是当我选择查看按钮以查找所选索引的主键值列时,我收到错误。 请帮我解决这个问题。 <%—-%> <asp:TextBox ID ="txtQuestion" Text ='’ runat =”server” TextMode =”MultiLine” Height=”100″ Width =”350″> <%– –%> <%– <asp:TextBox ID ="txtQuestion" Text ='’ runat =”server” TextMode =”MultiLine” > –%> <asp:Label ID ="lblPosterName" Text ='’ runat =”server” > <asp:Label ID ="lblDateTime" Text ='’ runat =”server” > 我的代码是…… protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { try { […]

entity framework中是否不支持通用类作为模型?

我想做这样的事情: public class TrackerContext : DbContext { public bool TrackNewValues { get; set; } public TrackerContext(bool trackNewValues = false) : base() { TrackNewValues = trackNewValues; } public TrackerContext(string connectinString, bool trackNewValues = false) : base(connectinString) { TrackNewValues = trackNewValues; } public DbSet<AuditLog> AuditLog { get; set; } public DbSet LogChildren { get; set; } } […]