草庐IT

page-state

全部标签

c# - 重写 ASP.NET 代码隐藏文件中的 Page 类构造函数——何时调用?

如果我覆盖System.Web.UI.Page构造函数,如图所示,DoSomething()在页面生命周期方面何时被调用?我似乎无法在任何地方找到这个记录。namespaceNameSpace1{publicpartialclassMyClass:System.Web.UI.Page{publicMyClass(){DoSomething();}protectedvoidPage_Load(objectsender,EventArgse){}}}作为引用,这里是ASP.NET页面生命周期概述:http://msdn.microsoft.com/en-us/library/ms17847

c# - Db Connection.State Change 什么时候调用?

我有以下代码:classProgram{staticvoidMain(){varconnection=newSqlConnection("myConnectionString");connection.Open();connection.StateChange+=HandleSqlConnectionDrop;Console.WriteLine("Hi");Console.ReadLine();}privatestaticvoidHandleSqlConnectionDrop(objectconnection,StateChangeEventArgsargs){Console.Writ

c# - 错误 :- The XmlReader state should be Interactive on XDocument. 加载

我收到以下错误:-System.InvalidOperationException:TheXmlReaderstateshouldbeInteractive.atSystem.Xml.Linq.XContainer.ReadContentFrom(XmlReaderr,LoadOptionso)atSystem.Xml.Linq.XDocument.Load(XmlReaderreader,LoadOptionsoptions)在下面的代码中。谁能指出我在这里做错了什么?staticXDocumentGetContentAsXDocument(stringxmlData){XmlDoc

c# - LinqToSQL 错误 : Operation is not valid due to the current state of the object

在更新命令期间,我收到以下错误:Operationisnotvalidduetothecurrentstateoftheobject我试图从更新命令中删除一列并且它工作正常。此列是一个FK,与其他工作正常的FK相似。这是执行更新的代码:ti.NumeroTitolo=titolo.Numero;ti.RKTipoTitoloGenereTitolo=titolo.RkTipoTitoloGenereTitolo;ti.RKBanca=titolo.RkBanca;ti.DataScadenza=titolo.DataScadenza;ti.RKTipoEsito=titolo.RkTi

c# - ASP.NET : Check for click event in page_load

在C#中,如何检查是否在页面加载方法中单击了链接按钮?我需要知道在触发点击事件之前它是否被点击。 最佳答案 if(IsPostBack){//getthetargetofthepost-back,willbethenameofthecontrol//thatissuedthepost-backstringeTarget=Request.Params["__EVENTTARGET"].ToString();} 关于c#-ASP.NET:Checkforclickeventinpage_lo

c# - "Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context"

我不知道这个错误是什么意思。我使用的是VisualStudioforMac7.5.0社区版。我在带有ASP.NETCore的EntityFramework中使用延迟加载。publicpartialclassAdminUser{publicAdminUser(){RoleAssign=newHashSet();}publicGuidUserId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicstringEmail{get;set;}publicstringUserName{get;s

c# - MVC3 Layout Page、View、RenderPartial 和获取脚本文件到 Header(从局部 View )

所以我有一个布局页面@RenderSection("HeaderLast",required:false)一个View@sectionHeaderLast{}@{Html.RenderPartial("_userProfile");}还有局部View@sectionHeaderLast{alert('test');}我想这不可能那么简单。是否有一种开箱即用的正确方法,或者这是否总是需要某种中介并在ViewData周围传递内容以手动使内容冒泡到布局页面?赏金开始:赏金将奖励给为这个短时间提供的最佳解决方案。如果没有提供答案,我会将其奖励给最初回答这个问题的@SLaks。

c# - 如何避免 "Response.Redirect cannot be called in a Page callback"

我正在清理一些遗留框架代码,其中很大一部分只是通过异常编码。没有检查任何值以查看它们是否为空,因此会抛出和捕获大量异常。我已经清理了其中的大部分,但是,有一些错误/登录/安全相关的框架方法正在执行Response.Redirect,现在我们正在使用ajax,我们得到了很多"不能在页面回调中调用Response.Redirect。”我想尽可能避免这种情况。有没有办法以编程方式避免此异常?我正在寻找类似的东西if(Request.CanRedirect)Request.Redirect("url");请注意,Server.Transfer也会发生这种情况,因此我希望能够检查我是否能够执行R

c# - 无法将类型为 'ASP._Page_Areas_Admin__ViewStart_cshtml' 的对象转换为类型 'System.Web.WebPages.StartPage'

我创建了一个名为“Admin”的区域。在/Areas/Admin/Views/中,我有_ViewStart.cshtml:@{Layout="~/Areas/Admin/Views/Shared/_Layout.cshtml";}当我访问/Admin/中的页面时出现以下错误:无法将类型为“ASP._Page_Areas_Admin__ViewStart_cshtml”的对象转换为类型“System.Web.WebPages.StartPage”。我根据HowdoIuseacommon_ViewStartinareas?进行了建议的更改.我在根目录下的web.config中有这个,在/A

c# - TaskCompletionSource 抛出 "An attempt was made to transition a task to a final state when it had already completed"

我想使用TaskCompletionSource来包装MyService这是一个简单的服务:publicstaticTaskProcessAsync(MyServiceservice,intparameter){vartcs=newTaskCompletionSource();//EverytimeProccessAsynciscalledthisassignstoCompleted!service.Completed+=(sender,e)=>{tcs.SetResult(e.Result);};service.RunAsync(parameter);returntcs.Task;}