Subscribe: Custom Server Controls
Added By: Feedage Forager Feedage Grade B rated
Language: English
code  context  control  data  gridview  length  new  nextjeneration webui  public  result  return  route  system  val length  val 
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: Custom Server Controls

All Forums

All Forums

Last Build Date: Mon, 18 Dec 2017 13:27:08 -0800


[HttpGet("{id}", Name = "GetTodo")]


What does the highlighted line accomplish below?

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using TodoApi.Models;
using System.Linq;

namespace TodoApi.Controllers
    public class TodoController : Controller
        private readonly TodoContext _context;

        public TodoController(TodoContext context)
            _context = context;

            if (_context.TodoItems.Count() == 0)
                _context.TodoItems.Add(new TodoItem { Name = "Item1" });

        public IEnumerable GetAll()
            return _context.TodoItems.ToList();

       [HttpGet("{id}", Name = "GetTodo")]

        public IActionResult GetById(long id)
            var item = _context.TodoItems.FirstOrDefault(t => t.Id == id);
            if (item == null)
                return NotFound();
            return new ObjectResult(item);

c# testing a webMethod using IQueryable works but does not after publishing


I have developed web services using c# for a while now. And everything up till now worked fine, but today even though while debugging the code runs fine like it has been for few months now but when i publish the code and put it on a IIS it gives and error. the message is: The type or namespace name 'AKAB_Item_AKItem' could not be found the code which works while debugging but crashes when published. IQueryable akitemsswe = null; if (date_last_modified != null) { akitemsswe = from result in dc2.AKAB_Item_AKItems where result.Last_Date_Modified > DateTime.ParseExact(date_last_modified.ToString(), "dd.MM.yyyy HH:mm:ss", null) select result; } else { akitemsswe = from result in dc2.AKAB_Item_AKItems select result; } Am I missing something because i can not wrap my head around that the debugging works but the published project does not. And just to be sure - I have inspected the published files and the *.dbml contains  AKAB_Item_AKItem [...]

4.5 dynamic table I can't read it


We just moved to 4.5.

We have a dynamically created asp table with drop down and text box controls on it.

There is a button that issues a post back and were trying to read the fields. Say someone changed a textbox text from 1 to 2.

On post back the field is Nothing. The 3.5 code use to read the table by Request.Item("statusb"). Now nothing comes.

If I read the controls with FindControl I get the values that was there before.

Any help would be appreciated.

Jon T

changes are not allowed if the project wasn't built when debugging started


I have googled this and found lots of suggestions on what to do, but none of them work.

This was working just fine last week.  The only thing I've installed in the last week was SSMS 2016.

If anyone who has ideas on how to get passed this, I would appreciate it!

How to call an API to search a database from an ASP.Net MVC application


I have an ASP.Net Core MVC website. I also have an ASP.Net Web API. I created a simple search function within the API to search an Oracle database with a search term input by a user into a textbox. What I want is to do the search from the MVC application. So I need to call the API and send it the search term, then return any results for display back to the MVC app. I believe I need to use GET to bring back data. Is there an example I could use? I am using Visual Studio 2017 and C#. Any help would be appreciated.

Deploying WebAPI


Is there a good tutorial someone can recommend for (non Azure) deployment of WebAPI?

Exporting names to CSV, take two columns instead of one


How do I get my name column to be one, stead of splitting as two? The output looks like this:


I would like to surround the column separators with quotation marks like

"0","jdoe","Doe, John"

Here's the code:

            Response.ContentType = "text/plain";
            Response.AddHeader("Content-Disposition", "attachment; filename=DownloadedData.csv;");

            StringBuilder sb = new StringBuilder();

            string[] columnNames = dt.Columns.Cast().
                                              Select(column => column.ColumnName).
            sb.AppendLine(string.Join(",", columnNames));

            foreach (DataRow row in dt.Rows)
                string[] fields = row.ItemArray.Select(field => field.ToString()).
                sb.AppendLine(string.Join(",", fields));
            // the most easy way as you have type it

IISADMPWD change password with e-mail


We use IISADMPWD webapplication to allow users to change their AD account password. Some of our AD accounts dont have the same UPN as mail, but we are changing that for the new users. So the new users now have the same on both UPN and mail. Can I somehow add or modify IISADMPWD so it accept users e-mailaddress when changing password? Today it only works with UPN, is it possible to replace the attributes in the code to support mail instead? or perhaps add a feature to "search for users with this mail"? or search for user by mail and then get the users UPN to continue changing password? I believe the development of this feature should be made in the achg.asp file I found this vbscript But dont know how to implement it in a .asp file. Tried just to paste the script into <%  %> but got Internal error 500. Can anyone help me with this? Or is there another method that's better for me? I dont know how to code ASP C# ASP.NET. But Im comfy with powershell, lokal VBScript and PHP. Sincerely Fredrik [...]

data connect to a web form control


Of the code listed above, can you tell me how the following statement knows how to connect the values listed below in the statement:  DataKeyNames="schoolyear, schoolnum, stulink, milestone_code, semester" to the gridvbiew control? Are these connected fields based upon following logic:     ', '<%# Eval("schoolnum") %>', '<%# Eval("milestone_code") %>', '<%# Eval("stulink") %>', '<%# Eval("HOMELNGCOR") %>', '<%# Eval("semester") %>');" style="color:Blue"><%#Eval("STUDENTNAME")%> If so, how does the javascript know how to connect the data to this gridview control? Here is the code to GetStudentLetterTemplate  function GetStudentLetterTemplate(schoolyear, schoolnum, milestone, studentlink, language, semester) {             if (language == '') {                 language = 'EN'             }             else if (language == 'SPA') {                 language = 'ES'             }             _schoolyear = schoolyear;             _schoolnum = schoolnum;             _milestone = milestone;             _studentlink = studentlink;             _language = language;             _semester = semester;             $('#<%= txtStuLink.ClientID%>').val(studentlink);             $('#<%= txtLanguage.ClientID%>').val(language);             var strData = "schoolyear: " + JSON.stringify(schoolyear) + ", "                 + "schoolnum: " + JSON.stringify(schoolnum) + ", "                 + "milestone: " + JSON.stringify(milestone) + ", "                 + "studentlink: " + JSON.stringify(studentlink) + ", "                 + "language: " + JSON.stringify(language) + ", "                 + "semester: " + JSON.stringify(semester) + "";             //alert('student data: ' + strData);             //make call to db and send ingredient information              $.ajax({                     type: "POST",               [...]

Int Parameter



   I am displaying values in Month Parameter as 1,2,3,4,5,6,7,8,9,10,11,12.

In a report i want to display its Label Value.


datakeys for gridview control


In a 2010 web form application, I see that there is a gridview control that use datakeys. When I do a search on the web, it looks like datakeys are only used up until visual studio 2010. Is this correct? If so, what control/property/ and/or  logic is used to replace the data keys control on a gridview control?

If this is not true, up until what version of visual studio can I use for a gridview control?

Error: AmbiguousActionException: Multiple actions matched.


I'm new to Core and I'm getting this error, what is the cause how do I fix it?

An unhandled exception occurred while processing the request.

AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:

NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)
NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)

Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList candidates)

  • AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied: NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI) NextJeneration.WebUI.Controllers.HomeController.Index (NextJeneration.WebUI)

Here is my Controller:

public class HomeController : AmtesControllerBaseController
        public HomeController(IUserRepository repository, NextJeneration.Domain.Concrete.NextJenerationDbContext context) : base(repository, context)

        [Route("")]      // Combines to define the route template "Home"
        [Route("Index")] // Combines to define the route template "Home/Index"
        [Route("/")]     // Does not combine, defines the route template ""
        public async Task Index()
            bool loggedIn = GetLoggedInStatus();
            if (loggedIn == false)
                var myCAC = getCAC();
                await buildCACuser(myCAC);
            return View();

        [Route("LandingPage")] // Combines to define the route template "Home/LandingPage"
        public IActionResult LandingPage()
            UserEditViewModel userEditViewModel = new UserEditViewModel();
            var CAC = GetCacInfo();
            var user = userRepository.GetUserByCAC(CAC);
            userEditViewModel.UserStatusId = user.UserStatusId;
            userEditViewModel.Registered = user.Registered;

            if (!user.ThemeId.HasValue)
                userEditViewModel.Theme = "~/lib/bootstrap/dist/css/bootstrap.css";
                userEditViewModel.Theme = userRepository.GetThemeById(user.ThemeId.GetValueOrDefault());

            ViewBag.CSS = userEditViewModel.Theme;

            return View("LandingPage", userEditViewModel);

        [Route("Error")] // Combines to define the route template "Home/Error"
        public IActionResult Error()
            return View();

validation stopped working


I am in desperate need of help. I used the following script to validate checkboxes and textboxes. The checkbox was outside gridview and the textboxes were inside gridview. User must either complete textboxes OR put a checkmark to the checkbox in other to submit the form. Management has decided that the checkbox must be inside gridview as well. As a result, I modified the script as shown below and now, the script doesn't valid anymore. It doesn't matter whether the checkbox is not checked and the textboxes are empty, it still submits. How do I change to class so it would be able to validate? This is what I am currently using.

*Check this box if N/A
getstoredproccommand(“procedurename”,new object[1]) throws 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll


public static IEnumerable GetAll() { Database db = DatabaseFactory.CreateDatabase(); DbCommand objComm = db.GetStoredProcCommand("package name.procedurename", new object[1]); var result = new List(); using (IDataReader rdr = db.ExecuteReader(objComm)) { while (rdr.Read()) { result.Add(Construct(rdr)); } } return result; } and my store procedure is like this PROCEDURE PRC_PROCEDURE (resultset_out OUT TYPES.cursorType) AS BEGIN OPEN resultset_out FOR SELECT * FROM PORTALLISTS; END PRC_PORTALLISTS_GETALL; i am having error in this line DbCommand objComm = db.GetStoredProcCommand("package name.procedurename", new object[1]); if i do this DbCommand objComm = db.GetStoredProcCommand("package name.procedurename"); error is gone but then i am facing same error[Exception thrown: 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll] in this line using (IDataReader rdr = db.ExecuteReader(objComm)) . i am using framework 4 and Microsoft.Practices.EnterpriseLibrary.Data.dll version is can you guys pls help me? and in portallistservices.cs file i have this public static IEnumerable GetAll() { return GetAll(true); } private static IEnumerable GetAll(bool forceDataReload) { const string cacheKey = "PortalListService_GetAll"; IEnumerable result = null; if (!forceDataReload) result = GetFromCache(cacheKey); if (result == null) { result = PortalListRepository.GetAll(); AddToCache(cacheKey, result); } return result; } [...]

How to load partialview into bootstrap modal dynamically


suppose i have a button and when user will call then i will call a server action which will return partial view to client side means html with data. i need to show and put that data into  bootstrap modal dynamically. how it will be possible.

i will not leave bootstrap modal in advance in page rather bootstrap modal will be constructed at run time dynamically.

please give me code sample or article links.

Receiving live data on server


Live weather data needs to be sent to my server 2012, so far i have created a .Net web page which can read query string and save it to some file on server. Its been hosted on IIS 8.0. Eaxmple(

I was wondering if this is a right way of receiving data on server? the other idea i had in mind was soap web services but not sure if it can add any benefits to what i have already done.

protected void Page_Load(object sender, System.EventArgs e)
  if (Request.QueryString.Count > 0)
    string query = Request.QueryString("str");
    using (StreamWriter _testData = new StreamWriter(Server.MapPath("~/data.txt"), true))

Disable ChangeTracking with EF 6.0


I am wondering how can I really disable ChangeTracking per entity using Entity Framework 6.0 by calling AsNoTracking() method.

Here's my DataContext

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Validation;
//using System.Data.Objects;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace OrgData
	public class DataContext : DbContext, IDbContext
		#region Constructors
		static DataContext()
			// Set the db initialize to null so EF doesn't try to create our database for us

		public DataContext(): base ("Name=Conn")
			this.Configuration.AutoDetectChangesEnabled = false;

		#region Data Sets
		public DbSet Projects

Could not install any of those packages!

Any help would be appreciated.

How to detect request is coming from mobile or tab


with the help of javascript or jquery can we detect that request is coming from mobile or tab instead of desktop pc or laptop pc?

if possible please share the code. thanks

repeater group by


I have records in my sql server db :

ID | StudyName|  StudyText    | StudyLink                         

1      study1         about ENR      

2      study1         about ENRA   

3      study2         about ENR   

I want to group the data so that the repeater will show me :


about ENR

about ENRA  


study2         about ENR  

any hint ?

Convert PHP Application to


Hi All,

There is a requirement where I need to convert PHP Application(what ever normal php pages or wordpress) to Please let me know if there are any readymade for conversion. Its urgent for me.  Thanks in Advance