Subscribe: Visual Web Developer 2005 Express
Added By: Feedage Forager Feedage Grade B rated
Language: English
button  controller  data  error  list  model  new xelement  new  routedata values  routedata  runat server  runat  server  values  web 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Visual Web Developer 2005 Express

All Forums

All Forums

Last Build Date: Thu, 22 Feb 2018 19:31:04 -0800


Error is raising when i am working with EditorTemplates


i am trying to learn how to work with EditorTemplates. i need to show data in tabular format. i want to show student information like ID, Name, Country, Hobbies and Sex. i want to do this with EditorTemplates. two area throwing error called An exception of type 'System.Web.HttpCompileException' occurred in System.Web.dll but was not handled in user code Additional information: External component has thrown an exception. one area is country dropdown and another one area is sex radio buttons which causes the error. 1) @Html.DropDownListFor(m => m.CountryID, new SelectList((List) ViewBag.Countries, "ID", "Name", m.CountryID), "-- Select Country--") 2)
@Html.HiddenFor(m => m.ID) @Html.HiddenFor(m => m.SexName) @Html.RadioButtonFor(m => m.ID, Model.ID) @Html.LabelFor(m => m.ID, Model.SexName)
here is my full code Main View @model EditorTemplateSample.Models.StudentListViewModel @{ ViewBag.Title = "Home Page"; }

@using (Html.BeginForm("Index", "Home", FormMethod.Post)) {
@**@ @for (int x = 0; x <= Model.Students.Count - 1; x++) { @Html.EditorFor(m => m.Students[x], new { Countries = Model._Countries, Sex=Model._Sex }) }
ID Name Country Hobbies Sex
} Shared\EditorTemplates\Student.cshtml @model EditorTemplateSample.Models.Student @Html.TextBoxFor(m => m.ID) @Html.TextBoxFor(m => m.Name) @Html.DropDownListFor(m => m.CountryID, new SelectList((List) ViewBag.Countries, "ID", "Name", m.CountryID), "-- Select Country--") @Html.EditorFor(m => m.Hobbies) @Html.EditorFor(m => m.Sex) Shared\EditorTemplates\Hobby.cshtml @model EditorTemplateSample.Models.Hobby
@Html.HiddenFor(m => m.ID) @Html.HiddenFor(m => m.Name) @Html.CheckBoxFor(m => m.Checked) @Html.LabelFor(m => m.Checked, Model.Name)
Shared\EditorTemplates\Sex.cshtml @model EditorTemplateSample.Models.Sex
@Html.HiddenFor(m => m.ID) @Html.HiddenFor(m => m.SexName) @Html.RadioButtonFor(m => m.ID, Model.ID) @Html.LabelFor(m => m.ID, Model.SexName)
View model namespace EditorTemplateSample.Models { public class StudentListViewModel { //public List Country { get; set; } public List _Countries { get; set; } public IList Students { get; set; } public List _Sex { get; set; } public StudentListViewModel() { Students = new List { new Student { ID=1,Name="Keith",CountryID=0,SexID="F", Hobbies= new List { new Hobby{ID=1,Name="Football",Checked=true}, new Hobby{ID=2,Name="Hocky",Checked=false}, new Hobby{ID=3,Name="Cricket",Checked=false} } }, new Student { ID=2,Name="Paul",CountryID=2, Ho[...]

How come the event.preventDefault() does not work for lthis special case?


Hi, In my razor view, I have an action button which calls a method of controller which works fine. Here is the codes: var btnReset = document.getElementById("GenerateButton"); btnReset.onclick = function () { var sel = document.forms[0].ChooseRight; //Check if any item has been added to ChooseRight listbox if (sel.options.length == 0) { alert("Please move report column(s) from left to right 1.");   event.preventDefault(); } else { for (var i = 0; i < sel.options.length; i++) { sel.options[i].selected = true; } } }; And there is a "Generate" method on "Report"  controller like this: [HttpPost] public ActionResult Generate(string button, ReportViewModel viewModel, List ChooseRight, string WildCardProdType) { The above codes works well when I click the Generate button, and it calls the Generate(...) method properly, and the JavaScript validation is also working well, the event.preventDefault()  works well. Now, I want to replace this button with ajax call, so I changed the above button as below: And here is the javascript codes with ajax call: function SubmitButtonOnclick() { var sel = document.forms[0].ChooseRight; var selectedItems = []; if (sel.options.length == 0) { alert("Please move report column(s) from left to right.2"); // this prompts is still working, but the codes below does not stop the code, instead, it is still calling the Generate method of controller. //event.preventDefault(); return false; } else { for (var i = 0; i < sel.options.length; i++) { sel.options[i].selected = true;  } $('#ChooseRight :selected').each(function(n, selected) { selectedItems[n] = $(selected).val(); });  $.ajax({ here is ajax call starts there..... Does anybody know why my modified codes above is still calling the method of controller? why the return false, or return event.proventDefault() does not stop the javascript code and continuing calling the controller method? Thanks [...]

MVC Web API template's Values API error “This File does not have a Program Associated with it for Performing This Action”



I'm using Visual Studio 2017.  I created a new project by selecting the C#->web application -> MVC + WEB API both template boxes checked.  There are 2 default controller that comes with this template, Home and Values.  I built and ran the program and the home page display just fine.  However, when I call the values Get or Get id, I get pop up message at the bottom of the screen asking if I want open of save, I think it's referring to the json file the it's returning.

If I select Open then I would get the error msg as described in the Subject of this question.  I googled on the web and there are like 3 different ways to fix this in Regedit.  Can someone here point me to the correct one?

(image) How does one insert screen cap images here?  I give it a local pc path but nothing is uploaded! 

Entity Framework - two connection strings in web.config


Hello everybody,

I have Database in SQL Server, using this for Identity, in my web.config the connection string is like this:

After I add some tables for a project in a same Database and by ADO.NET genarated this tables in Models in my project, it made another connection string to my project, in web.config:


Do I need two connection strings in my web.config for a same database?

If not, how I can join this into unique connection string?

Do i gonna have a problem in deployment of my application to the server with two connection strings?

What is the best practice to deal with connection strings in this contest Database first?

Thank you :)

I have problem .


I'm designing a darts game in C #, and I'm having a problem with scoring. For example, when I want to hit the edge of a circle, for example, score 25 points when the darts hit the middle,
Im 14 please help me

SQL Server Query: Fast with Literal but Slow with stringlist


Hi all,

I am facing sql select statement performance issue. If I query the data like this it runs in less than a second

SELECT * FROM Emloyee WHERE employeeLogin in ('john1','step10')

However, if I query the data like this, its took about 10seconds. Anyone facing similar problem? Anyone can guide me how to go about this?

DECLARE @employeeNTLogin varchar(200) = john1,step10
SELECT * FROM Emloyee WHERE employeeLogin in (select * from fn_SplitStringList (@employeeNTLogin,','))

Below is my function:

Create FUNCTION [dbo].[fn_SplitStringList] (@list VARCHAR(MAX), @separator VARCHAR(MAX) = ';')



DECLARE @position INT, @previous INT

SET @list = @list + @separator

SET @previous = 1

SET @position = CHARINDEX(@separator, @list)

WHILE @position > 0 BEGIN

IF @position - @previous > 0

INSERT INTO @table VALUES (SUBSTRING(@list, @previous, @position - @previous))

IF @position >= LEN(@list) BREAK

SET @previous = @position + 1

SET @position = CHARINDEX(@separator, @list, @previous)



error could not load file or assembly 'file:///c:\windows\\framework64\v4.0.30319\temporary files\root\99372b34\847fb083\app_global.asax.gfeczrle.dll' or one of its dependencies.



May I know what causes this error:

could not load file or assembly 'file:///c:\windows\\framework64\v4.0.30319\temporary files\root\99372b34\847fb083\app_global.asax.gfeczrle.dll' or one of its dependencies.

I deployed my application and it works fine but suddenly after some days, it throws this error. Then I need to publish the bin folder again and it starts working. I tried many solutions from Google but to no avail.

Please suggest how can I fix this.


Show a TAB


How to show a TAB, within HTML file?

Insert white Spaces in XML to LINQ generated document


I am using the following code to generate the XML.

 XElement contacts =
new XElement("Contacts",
new XElement("Contact",
new XElement("Name", "Patrick Hines"),
new XElement("Phone", "206-555-0144",
new XAttribute("Type", "Home")),
new XElement("phone", "425-555-0145",
new XAttribute("Type", "Work")),
new XElement("Address",
new XElement("Street1", "123 Main St"),
new XElement("City", "Mercer Island"),
new XElement("State", "WA"),
new XElement("Postal", "68042")
This gives me

Patrick Hines

123 Main St
Mercer Island

but I want to generate an XML with white Spaces/newlines in before few elements. For Eg:
if I want to push few elements to the right like below..

          Patrick Hines

                     123 Main St
                       Mercer Island

I am reading this generated XML into a tool which needs such weird spacing in XML files else it fails reading XML files.

I am not sure if generating the above XML is possible with LINQ to XML or should I use XMLTextWriter ?

what are the IDENTITY counterparts to these outdated SQL-membership functions


The following are all SQL-Membership functions that I have been using in my website.   I now want to port to IDENTITY, but I don't know what to replace them with:

Roles.GetRolesForUser(username) returns list
email - Membership.getusernamebyemail(username)

My question is, are there IDENTITY counterparts to these, and if so, how do I look them up?

How can i make my GridView only shows data based on a search field for example my Autogenerated ID


so I want my GridView only shows data based on my search and there should be edit and delete and update within the gridview itself also I tried by my own but when I link the textbox search that is linked with my database using sqldatasource then link that with the gridview the search works but it will ask me to refresh and then the edit and delete and update will disappear <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditDelete.aspx.cs" Inherits="test.EditDelete" %>

 Create New Records/Print Forms    Search For Records Based on Vendor Name     

Search Records by Date::  

Where to put statements of the Sum of a Datatable Column in MVC


Hi there, I am trying to get the sum of a datatable column in my project and display is as a label saying 'Total', but I am unsure of where to place this code.

At present, I am placing it in the controller of the, but it does not accept the label from the code snippet I was recommended to use. 

My code is: 

   private void ComputeBySales(DataSet dataSet)
            // Presumes a DataTable named "Orders" that has a column named "Total."
            DataTable table;
            table = dataSet.Tables["Sales"];

            // Declare an object variable.
            object sumObject;
            sumObject = table.Compute("Sum(Total)", "");

// this line not accepted lblTotalAmount.Text = sumObject.ToString(); }

As I am relatively new to MVC I do not know where or how to code this label, so any help would be appreciated

Script not triggering


I have a script that I need to trigger when a value from a dropdown is selected in order to hide or show certain fields.  I'm testing it now, and it doesn't seem to hide or show fields based on the class.  What am I doing wrong on this script? Code is below:

@model APTII_MVC.ViewModel.ProjectViewModel 

    ViewBag.Title = "Edit";

@Model.Project.Project_ID - @Model.Project.EmployerRef

@using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) @Html.DropDownListFor(model => model.Project.APT_ProjectTypes.BusinessType_ID, new SelectList(Model.BusinessTypes, "ID", "Description"), new { Name = "BusinessType" })
This worked?

How do I access routedata values set in Application_Error event inside Controller Action


I have tried out the code provided here but it is not working for me. I'm only receiving two values from RouteData that is action and controller, Below is my code: I have already tried to save object data to a Session, TempData, I have also tried an Interface implemented by the Controller but nothing seems to work for me. I would really appreciate any pointers and insights as I know not what to do anymore. protected void Application_Error(object sender, EventArgs e) { new ErrorHandler(Server.GetLastError(), HttpContext.Current); }public ErrorHandler(Exception exception, HttpContext context) { Task.Run(async () => { await HandleError(exception, context); }); }//Function invoked inside Application_Error Event private async Task HandleError(Exception exception, HttpContext context) { var errorType = string.Empty; var httpException = exception as HttpException; if (httpException == null) { httpException = new HttpException(500, "Internal Server Error", exception); } //Clears all content from the buffer stream context.Response.Clear(); RouteData routeData = new RouteData(); var errorController = new ErrorController(); routeData.Values.Add("controller", "Error"); **routeData.Values.Add("requestHelper", new HtmlRequestHelper(context)); //Can't get this object in Action Method** switch (httpException.GetHttpCode()) { case 403: errorType = "Http 403 : Access denied"; routeData.Values.Add("action", "Restricted"); break; case 404: errorType = "Http 404 : Resource not found"; routeData.Values.Add("action", "NotFound"); break; case 500: errorType = "Http 500 : Internal Server Error"; routeData.Values.Add("action", "ServerError"); break; default: errorType = "Http " + httpException.GetHttpCode() + " : General Application Error"; routeData.Values.Add("action", "GeneralError"); break; } // Clear the error from the server context.Server.ClearError(); // Log the exception and notify system operators new LogError(exception, "Application_Error(object sender, EventArgs e)", context); // Notify system admin about the error via email service. await new MessageService(new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings["AdminOne"].ToString()), "PMS: Application Error", errorType + " : " + exception.Message, null).ProcessQueue(); **errorController.ControllerContext = new ControllerContext { RouteData = routeData };** IController controller = errorController; controller.Execute(new RequestContext(new HttpContextWrapper(context), routeData)); } //Action Method inside ErrorController [HttpGet] public ActionResult ServerError() { try { **if (RouteData.Values.ContainsKey("requestHelper")) //nothing here** { ViewBag.RouteData = (HtmlRequestHelper)RouteData.Values["requestHelper"]; } } catch (Exception err) { new LogError(err, "[Controller: Error] [Action Method: ServerError()]"); } //Redirect HTTP errors to HttpError page return View[...]

ASPX Deployment Issue - PublicKey Token could not be located


I have searched blogs, forums, and internet for a solution. Recommendations abound, including using NuGet to change my environment, change my project to "Application", copy the codedom to the GAC, bin directory missing. After all these years of this error plaguing IIS, there should be a solution that doesn't run me around the world trying hundreds of things. Does anyone know what it is?

Please help, I have been stuck two days on this.

I am building my first web app using the community 2017 verision if VS. I am deploying to Windows 10 IIS Express. The app runs in the VS, fails in IIS localhost.

I believe my environments should be compatible, please see below.

Parser Error Message: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.

Line 49:
Line 50:
Line 51:
Line 52:
Line 53:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll in folder C:\inetpub\wwwroot\TicketManager\bin

File version: 1.0.40810.0

product version: 1.0.7-40810

Event listener in Web API


I have a windows project which is using 3 party dlls to communicate. this 3 party dlls are also sending events which is been captured inside the windows project via events& delegates.

Note: the events fired by the 3 party dlls are the UDP packets.

I need to convert this project to Web API. I have added those dlls in my web api and I am able to communicate to send request and receive response via the dll's. Now, I have to receive the events from those dlls in web api.

Is there anything I can try to make it possible.

How to export data right?


I have a database with some data get by somewhere. 

Now i want to export the data to text files. But there can be many data. it can run many minutes.

  • I want to start export with one API call. In working state, no another call should can start another export. the export should mark each datarow (with subrows) after exporting
  • Another call should ask the export about his state
  • At finisch the export, the export should save an with state and notes in the database 

I have experimented and my actual code is not stable. Sometimes it break with no output or i get "New transaction is not allowed because there are other threads running in the session." Is there someway a tutorial how to build the scenario or any hints for me?

Ajax not working (Installed Microsoft.jQuery.....)


Hi All, is anyone have idea why Ajax seems not recognized even if I installed Nuget packages microsoft.jquery.Unobtrusive.Ajax and microsoft.jquery.Unobtrusive.Validation,

when I typed Ajax. in my cshtml file it has the red underline?

Thanks in advance.(image)


ListBox adding image on selected item


The Listbox selected items brings up a little square at the right side of the selected item, is there a way to change this to a checkmark or our own image?

jQuery/javascript not working until after refreshing the page


Hi, I'm using bootstrap css, javascript and jQuery, which looks ok when initially loading the page.  However, I'm not able to minize windows or open a popup with single click and double click or hovering over unless I refresh the browser, then it work fine.  It's the ajax but not sure how to fix this.  How can I refresh the page or controls that have the minize buttons and the popup windows?  I have a ListView, inside which I have another listview, inside which there's another listview.  Below is the general code.... I need to click on the "fa fa-minus" to minimize popUpData and popUpDetails are two pop that should come up on a single click. These don't work unless I refresh the page and I have to refresh it each time I change an item in the dropdown list.  How can I reload the javascript for this or make sure the page reloads these controls to work properly.

<%-- table class=table table-hover used div instead of table --%> [...]