Tag: asp.net

“指定的参数超出了有效值的范围”

我正在使用TextBoxes在ASP.Net GridView控件中添加动态行。 但是当我点击我的添加新行按钮时,我收到以下错误。 指定的参数超出了有效值的范围。 参数名称:index 可能是什么错误? 我的.aspx文件中的代码 ButtonAdd_Click()的C#代码 if (ViewState[“CurrentTable”] != null) { DataTable dtCurrentTable = (DataTable)ViewState[“CurrentTable”]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the TextBox values TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_type"); TextBox box2 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_total"); TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_max"); TextBox box4 = […]

在web.config中的appSettings中使用“&amp;”

我正在尝试将网站地址存储在web.config文件的appSettings部分中。 URL的末尾有两个查询字符串参数,因此我需要使用&符号。 当我在代码文件中对URL进行硬编码时,如果我替换”&” 。 在配置文件中,这些字母是红色的。 我试过“&”和”&” 在配置中,它们都变成红色,我无法从代码文件中读取它们。 任何人都可以告诉我如何做到这一点,它的工作原理? 谢谢, 编辑: 看起来它没有从appSettings中读取任何内容。 我正在使用此行来检索设置。 String surveyLink = ConfigurationManager.AppSettings[“SatisfactionSurveyLink”];

ASP.NET核心中的自定义RoleProvider与身份?

在过去的MVC版本中,我能够做到 <roleManager enabled="true" defaultProvider="…." … 在web.config中获取自定义角色提供程序,但似乎不再是这种情况。 基本上我想做的是: 用户登录。 成功时,从外部源获取用户角色。 将角色应用于用户以在代码中使用。 将用户角色与自定义RoleProvider中的角色相匹配 我如何在ASP.NET Core中执行此操作?

Response.TransmitFile()的替代方案

所以我有一套我过去几天一直在玩的代码,我需要从服务器下载一个文件到客户端。 这是一个简单的部分,但我还需要在完成后刷新网格视图并在警报中显示文件已成功创建,但我发现下载的每一种方式都包含一行代码,这将是我的倒台。 到Response.End() Response.Close()或 ApplicationInstance.CompleteRequest() 所有这些都结束了当前的响应,或者我相信在ApplicationInstance的情况下,它将页面的所有源代码刷新到我试图下载的文本文件中。 下面是我从服务器下载文件的代码片段,以下是下载文件的源代码。 如果你有任何可以帮助解决这个永无止境的噩梦,那将非常感激。 //I brought everything together in an arraylist to write to file. asfinalLines = alLines.ToArray(typeof(string)) as string[]; string FilePath = HttpContext.Current.Server.MapPath(“~/Temp/”); string FileName = “test.txt”; // Creates the file on server File.WriteAllLines(FilePath + FileName, asfinalLines); // Prompts user to save file System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType […]

使用DotNetOpenAuth访问Yelp的OAuth 1.0a API

有没有人使用DotNetOpenAuth成功使用DotNetOpenAuth访问Yelp的v2 api ? 在深入了解示例和源代码之后,我就提出了这个问题: public class YelpConnector { private static readonly string YelpConsumerKey = ConfigurationManager.AppSettings[“YelpConsumerKey”]; private static readonly string YelpConsumerSecret = ConfigurationManager.AppSettings[“YelpConsumerSecret”]; private static readonly string YelpToken = ConfigurationManager.AppSettings[“YelpToken”]; private static readonly string YelpTokenSecret = ConfigurationManager.AppSettings[“YelpTokenSecret”]; private static readonly InMemoryTokenManager tokenManager = new InMemoryTokenManager(YelpConsumerKey, YelpConsumerSecret, YelpToken, YelpTokenSecret); private static readonly Uri YelpURLBase = new Uri(“http://api.yelp.com/v2/”); […]

EF4两个型号一个数据库,可能吗?

我一直在寻找这个答案,似乎找不到任何东西,但是对于EF4,我想创建一个基础模型并放入我们的“基础”和我们创建的任何新项目,如果我们需要向该站点db添加自定义表是否可以添加一个只有那些特定表格的模型并将其链接到我们的“基础”中的模型我似乎无法在这样的事情上找到一个好的资源,这似乎就像它是正常的有一个可重复使用的基础模型和一个单独的一个用于任何一个off 感谢您的帮助或指点!

C#文件导出问题

我使用此代码导出/打开文件(pdf / xls / doc)。 Response.Clear(); Response.Buffer = true; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Charset = “UTF-8”; Response.ContentType = mimeType; Response.AppendHeader(“content-disposition”, “inline; filename=” + fileName + “.” + extension); Response.BinaryWrite(bytes); Response.End(); 当我用Word打开一个doc文件并单击导出到xls或pdf时,在关闭Word之前没有任何反应。 关闭Word后,我已经能够打开xls和pdf了。 使用Excel打开xls时存在此问题。 是什么原因?

如何在GridView中禁用内联编辑?

我正在使用ASP.NET C#Grid View,我想编辑控件中显示在同一页面上的数据。 但是,当我写网格视图行编辑事件时,它在网格视图行中显示文本框,任何人都可以帮助我如何使用rowediting事件禁用网格视图中的内联编辑? <asp:LinkButton ID="lbView" runat="server" CommandName="View" Text="View" CommandArgument="”> <asp:HiddenField runat="server" ID="hdnItemID" Value='’>

用于generics类型的ASP.NET Web API模型绑定器

与对应的MVC问题一致 ,有没有办法在ASP.NET Web API中为generics类型创建模型绑定器? 如果是,那么如何在绑定器中处理类型检查和实例化? 假设模型绑定器用于URL参数,请考虑一下 [ModelBinder(typeof(MyTypeModelBinder))] public class MyType { //… } 和 public class MyTypeModelBinder : IModelBinder { public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { // check if type if valid? Something like this… if (!(bindingContext.ModelType.IsGenericType && bindingContext.ModelType.GetGenericTypeDefinition() == typeof(MyType))) { return false; } // create instance…using Activator? } }

如何在Ektron中选择属于分类的库项目

我正在使用Ektron CMS版本8.5 SP2。 我在分类中有一些项目。 有些是实际页面,有些是库项目(Word文件和PDF文档)。 假设我的分类中共有5个项目,共有3页和2个库项目。 我使用以下代码…… ContentManager cManager = new Ektron.Cms.Framework.Content.ContentManager(); Ektron.Cms.Content.ContentTaxonomyCriteria ctCriteria = new Ektron.Cms.Content.ContentTaxonomyCriteria(); ctCriteria.AddFilter(1707, true); // hard coded taxonomy ID List list = cManager.GetList(ctCriteria); Label1.Text = list.Count.ToString(); 当此代码运行时,列表中的项目数为3.如果我输出实际列表,我可以看到它只是分类中的页面,而不是2个库项目。 似乎ContentManager.getList()函数没有获取库项目,即使这些项目已添加到分类法中也是如此。 我可以确认在管理工作区中,库项目在分类中可见。 为了澄清,这是检索已添加到分类中的项目的问题。 有谁知道如何重新分类分类中的所有项目,包括那里的任何库项目。 注意:如果我将文件添加到Document Managment System而不是库中,它可以完美地工作。 但是在实时系统中,我在库中有数百个项目,我希望这是一种通过分类法查看它们的方法,而无需将它们全部移动到DMS中。 我也在Ektron开发者论坛上发布了这个问题,但我没有回复。 我希望这里有人可以提供帮助。 干杯。