Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim Button As System.Web.UI.WebControls.Button

    Dim x As Integer
    Dim y As Integer
    Dim name As Integer

    x += 10
    y += 10
    Label1.Text = x
    Label2.Text = y
    name = name + 1
    Button = New Button()
    Button.ID = "TextBox" & name
    Button.Style("Position") = "fixed"
    Button.Style("Top") = y & "px"
    Button.Style("Left") = x & "px"
End Sub

I want you to constantly produce new buttons on the page.

This question already has an answer here:

I am at a loss here, here is my code in my Model

 public class Movie
        public int Id { get; set; }
        public string Name { get; set; }


here is the code in my controller

public class MoviesController : Controller

        public ActionResult Random()
            var movie = new Movie();
            movie.Name = "Kevin";
            return View();

here is the code in my view

@model Vidly.Models.Movie
    ViewBag.Title = "Random";
    Layout = "~/Views/Shared/_Layout.cshtml";


Please help guys, I have no idea what I am doing wrong?

I run Visual Studio 2017 Enterprise as Administrator and select File > Open > Web Site > FTP Site. I log in to the site using an IP Address, start directory and a username and password in Passive mode. After the site loads, I right click the App_Code folder and select Add New Item, I select class and name of NewClass.cs. When I click add, I get an error dialog box that says

Cannot add the file 'C:\Users\LP\AppData\Local\Temp\l1w5g2.k.0ho\Class.cs' to the local cache. The system cannot find the path specified.

If I right click on the folder again and select Refresh folder it shows a file now called NewClass.cs. However, if I double click the file I get another error dialog box that says

Unable to get file 'NewClass.cs' from the Web server.

I cannot work on this website at all. I think I need to delete or clear the 'cache' but have no idea how to do that. The path mentioned above does not exist. Unsure how to make this project editable again.

I have a visual basic web site and in one of the pages, for some reason, when I view the codebehind, every reference to an element is underlined (using visual studio 2015) and gives me an " is not declared" message. This just started today. I have not made any changes to the code at all. Here is a sample of what I have:

In my pay_web.aspx:

    <div id="container">
    <section class="banner_media_full page_banner" role="banner" id="banner">
        <div class="row">
            <div id="banner_full">
                <h1>Get Started</h1>            
    <article class="row" id="content">
            <asp:Label ID="lblErrMsg" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>

and here is my code behind:

    Protected Sub Page_Load(sender As Object, e As EventArgs)
        Dim li As System.Web.UI.HtmlControls.HtmlGenericControl = DirectCast(Me.Page.Master.FindControl("liGS"), System.Web.UI.HtmlControls.HtmlGenericControl)
        li.Attributes.Add("class", "current-menu-item")
    Catch ex As Exception
        lblErrMsg.Text = "!" & ex.Message.ToString()
    End Try

The element lblErrMsg is undefined, as far as code behind is concerned.

I am at a complete loss. I can provide full page code if you want to see it.

Thanks for any suggestions. Jonathan

I am beginner in so may be I have stupid question, but I need some help. I have a model and controller MAIN, with read/write rules. I have a create action in MainController, and it works, but I need that one of the field be dropdown and it has options from another table of Department. I have searched answer but I have not get full answer. So if you can, help me. If need I will write codes. Thanks a lot.

I have a foreach loop creating CheckBoxes, causing them to all have the same ID. I've got some CSS but when you check any box it puts the css onto the first iteration, how do I add some dynamic ID sort of thing to only add the css to the selected box?


@foreach (var item in Model.Where(p => p.UserTable.ID == ViewBag.UserTableID))
            <div class="select">
                <input type="checkbox" id="select" name="" />
                <label for="select"></label>


.select {
width: 20px;
position: relative;

.select label {
    cursor: pointer;
    position: absolute;
    width: 20px;
    height: 20px;
    top: 0;
    left: 0;
    background: #eee;
    border: 1px solid #ddd;

    .select label:after {
        opacity: 0.2;
        content: '';
        position: absolute;
        width: 9px;
        height: 5.5px;
        background: transparent;
        top: 4.8px;
        left: 5.4px;
        border: 3px solid #333;
        border-top: none;
        border-right: none;
        transform: rotate(-45deg);

.select label:hover::after {
opacity: 0.5;

.select input[type=checkbox]:checked + label:after {
opacity: 1;

I have a simple event handler:

    import axios from "axios";

export default function handleUpdate(ev: Event) {
    console.log("Handle update triggered.");
    let trigger: HTMLElement = <HTMLElement>ev.currentTarget;
    let endPoint: string = trigger.getAttribute("data-item-endpoint");
    let itemID = trigger.getAttribute("data-item-id");
    let inputEls: NodeListOf<HTMLInputElement> = <NodeListOf<HTMLInputElement>>document.querySelectorAll(`[data-item-id=${itemID}`);
    let updatedObj = buildObj(inputEls);

    axios.put(endPoint, updatedObj)
        .then((res) => {
            alert("Updated item");
        }).catch((ex) => {
            alert("Sorry, an error has been encountered.");

 function buildObj(inputEls: NodeListOf<HTMLElement>) : any {
    let obj: any = {};

    for(let i: number = 0; i <inputEls.length; i++) {
    const inputEl: HTMLElement = inputEls[i];
    const prop = (<HTMLInputElement>inputEl).name;
    let val = "";
    if (inputEl.hasAttribute("type") && inputEl.getAttribute("type").toLowerCase() == "checkbox") {
        val = (<HTMLInputElement>inputEl).checked ? "true" : "false";
    } else if (inputEl.hasAttribute("type") && inputEl.getAttribute("type").toLowerCase() == "file") {
    } else {
        val = (<HTMLInputElement>inputEl).value;
    obj[prop] = val;

return obj;


The function is imported from a script:

    import SearchBar from "search_bar";
import handleUpdate from "./handleUpdate";

let searchBar = new SearchBar("editFilterContainer", "editTableContainer");

which is referenced in my layout file:

    <!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - Insurance Enrollment</title>

    <div class="container-fluid">
        <header class="row mb-5">
            <div class="col-md-4"><h1>Insurance Midam Admin</h1></div>
            <div class="col-md-8">
                @RenderSection("links", required: false)
    <div class="container">

<script src="~/Scripts/distr/main.js"></script>
<script src="~/Scripts/distr/admin.js"></script>
@RenderSection("scripts", required: false)

However, I whenever I attempt to attach the event to an HTML element (located in a View referencing the layout file), I receive a handleUpdate is undefined message (I have tried both with and without the parentheses).

    <option onclick="handleUpdate()"  value="true">Unenrolled</option>

Full View for Reference:

    @{Layout = "~/Views/Shared/_AdminLayout.cshtml";}
@model InsuranceMidAm.ViewModels.AdminEmployeeViewModel
    ViewBag.Title = "Manage Eligible Employees";

@section links {
    <nav id="adminNav">
            <li><a href="~/Admin/">Admin Home</a></li>
            <li><a href="~/Admin/agreements">Agreements</a></li>
            <li><a href="~/Admin/employees">Employees</a></li>
            <li><a href="~/Admin/plans">Plans</a></li>
            <li><a href="~/Admin/resources">Resources</a></li>

<h1>Manage Eligible Employees</h1>

<div data-filter-endpoint="/Admin/EditValidations" id="editFilterContainer" class="form-row">
    <div class="form-group col-sm-4">
        <label>Page: </label>
        <select id="pageNumber" class="form-control" name="pageNumber">
            @for (int i = 1; i <= Model.pagesAvailable; i++)
                if (i == Model.currentPage)
                    <option selected value="@i">@i</option>
                    <option value="@i">@i</option>
    <div class="form-group col-sm-4">
        <label>Search (Last Name)</label>
        <input class="form-control" oninput="resetPage()" type="text" name="nameSearch" />
    <div class="form-group col-sm-4">
        <label>Enrollment Status: </label>
        <select oninput="resetPage()" class="form-control" name="unenrolledOnly">
            <option value="false">All</option>
            <option onclick="handleUpdate()"  value="true">Unenrolled</option>


@{Html.RenderPartial("_EditValidationPartial", Model);}
@section scripts {
    <script>function resetPage() {
    document.getElementById("pageNumber").selectedIndex = 0


I am using webpack as my bundler:

    const path = require("path");
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    context: path.join(__dirname, "Scripts/src/"),

    entry: {
        main: "main.ts",
        admin: "admin.ts"

    output: {
        filename: "[name].js",
        path: path.resolve(__dirname, "Scripts/distr")
    resolve: {
        extensions: ['.js', '.jsx', '.ts'],
        modules: ["node_modules", "src"]

    module: {
        rules: [
                test: /\.tsx?$/,
                loader: 'awesome-typescript-loader'

    plugins: [
        new CleanWebpackPlugin("Scripts/distr/*", { exclude: "assets/*" }),



I am not experienced with using ES6 features with the Razor View Engine.

What am I missing? Any help would be appreciated.


I'm using Knockout to create a dynamic form. I have a table and the user can add new rows to the table via a button click. My Bootstrap selectpicker appears in the first row, but not in the new rows added by the button click. Here's a screenshot:

enter image description here

My research indicates that when the Bootstrap select is added dynamically (as it is in this case) it needs to be rendered each time. It can be rendered like so:


This seems to be the case because I have tried the render in several places in my code. However, despite several hours of tinkering, I have not been able to get it to render properly on every button click. Sometimes it renders two or more select pickers on each row, for example. Here is my full Razor page code:

@model Birder2.ViewModels.CreateObservationViewModel
@using Microsoft.AspNetCore.Identity
@inject UserManager<ApplicationUser> UserManager
@using Newtonsoft.Json
    string data = JsonConvert.SerializeObject(Model);
@section scripts{
    <script src="~/js/knockout-3.4.2.js"></script>
    <script src="~/js/knockout.mapping-latest.js"></script>
    <script src="~/js/createobservationviewmodel.js"></script>
    <script type="text/javascript">
        var createObservationViewModel = new CreateObservationViewModel(@Html.Raw(data));
        createObservationViewModel.Observation.LocationLatitude = @UserManager.GetUserAsync(User).Result.DefaultLocationLatitude
            createObservationViewModel.Observation.LocationLongitude = @UserManager.GetUserAsync(User).Result.DefaultLocationLongitude
<h2>Create an observation</h2>
    <div class="form-group">
        @* change to Partial View like Manage Index *@
        <span class="control-label" name="MessageToClient" data-bind="text: MessageToClient" />

    <div class="form-group">
        <label class="col-sm-2 control-label" for="Observation.ObservationId">Id:</label>
        <div class="col-sm-10">
            <span class="form-control" name="Obervation.ObservationId" data-bind="text: Observation.ObservationId@*, event: {change: flagSalesOrderAsEdited}*@" />

    <div class="form-group">
        <label class="col-sm-2 control-label" for="Observation.ObservationId">Date:</label>
        <div class="col-sm-10">
            <input class="form-control" data-bind="datePicker : Observation.ObservationDateTime" type="date" />
    <div class="form-group">
        <input class="form-control" name="Observation.LocationLatitude" data-bind="value: Observation.LocationLatitude" />
        <input class="form-control" name="Observation.LocationLongitude" data-bind="value: Observation.LocationLongitude" />
    <div class="form-group" spellcheck="true">
        <label class="col-sm-2 control-label" for="Observation.Note">Note:</label>
        <div class="col-sm-10">
            <input class="form-control" name="Observation.Note" data-bind="value: Observation.Note" />

    <hr />
    <hr />

    <table class="table table-striped">
            <th class="text-right">Quantity</th>
            <th class="text-right">Bird</th>
            <th><button class="btn btn-info btn-xs" data-bind="click: addObservedSpecies">Add</button></th>
        <tbody data-bind="foreach: ObservedSpecies">
                <td class="form-group"><input name="ObservedSpecies.Quantity" class="form-control input-sm text-right" data-bind="@*attr: {'id': 'Quantity_' + $index()},*@ value: Quantity@*, event: {change: flagSalesOrderItemAsEdited}*@" /></td>
                <td class="form-group">
                    @Html.DropDownListFor(m => m.Observation.BirdId,
                        new SelectList(Model.Birds, "BirdId", "EnglishName"),
                        @class = "form-control selectpicker show-tick",
                        data_bind = "value: BirdId",
                        title = "Choose a bird",
                        data_live_search = "true",
                        data_show_subtext = "true"
                <td class="form-group">delete</td>               

Can anyone offer any help on how I can render each selectpicker?


If I remove the bootstrap select, leaving it as an ordinary select list, everything works as expected. So it is just a matter of getting the Bootstrap select picker to render properly.

I am new to episerver CMS. I have installed episerver cms alloy sample site. Also I found the code to show the navigation menu on the "_Root.cshtml".


So I have used same code on my new website to render the navigation menu

 <nav id="topnavigation">         

The Navigation is not showing on my website. Can any one help me to implement navigation menu on my episerver cms website?

UPDATE: rewording for conciseness...

With an ASP.Net MVC project, is it possible to have web.config rewrite rules take precedence over MVC's RegisterRoutes() call OR can IgnoreRoute be called for just a specific domain?

I have a single MVC application that accepts traffic over multiple domains ( and, the application serves different content based on the requested host (i.e. it's multi-tenant).

I have a URL url rewrite (a reverse proxy) configured in web.config which should only apply to a specific host:

<rule name="Proxy" stopProcessing="true">
        <match url="proxy/(.*)" />
        <action type="Rewrite" url="{R:1}" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^(mydomain\.com|www\.mydomain\.com)$" />
            <set name="HTTP_X_UNPROXIED_URL" value="{R:1}" />
            <set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
            <set name="HTTP_ACCEPT_ENCODING" value="" />

However, an MVC application will seemingly only honour web.config configured routes if they're ignored from the application's RegisterRoutes() method with:


Which then, unfortunately, applies the ignore to both domains. Suggestions greatly appreciated...

Is it possible to page the results of a drop down. This drop down is created from a field named 'DataSet ID' from the model layer. At the minute this is implemented with a viewmodel.

I have experience paging with a view -> controller but not with view -> viewmodel -> controller.

Any help is greatly appreciated. Using razor - mvc.

i want to delete row permanently from database via delete button.

this is my button code in a form that sends id to destroy function.

{!! Form::open(array('url' => 'admin/newsmaster/'.$value->id, 'class' => 'form-horizontal create_form', 'files' => true)) !!}
    <input type="hidden" name="_method" value="delete">
    <button type="submit" class="btn red">Delete</button>

this is my destroy function:

public function destroy($id)
        $feed= Feed::find($id);
        Session::flash('message', 'News Deleted Successfully.');
        $redirect = 'admin/newsmaster';
        return Redirect::to($redirect);

this is my Feed model:

protected $table = 'feed_news';
use SoftDeletes;
protected $softDelete = true;
protected $dates = ['deleted_at'];

my problem is when i click on delete option my row in database doesn't get deleted, instead it updates the deleted_at column.

Im trying to implement repository and unitOfWork pattern, like the following:

    internal CentralEntities context;
    internal DbSet<TEntity> dbSet;

    public GenericRepositoryTest(CentralEntities context)
        this.context = context;
        this.dbSet = context.Set<TEntity>();

    public virtual IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "")
        IQueryable<TEntity> query = dbSet;

        if (filter != null)
            query = query.Where(filter);


        foreach (var includeProperty in includeProperties.Split
            (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            query = query.Include(includeProperty);

        if (orderBy != null)
            return orderBy(query).ToList();
            return query.ToList();

Here is my UnitOfWork:

   private   CentralEntities context = new CentralEntities();
   private GenericRepositoryTest<User> usrRepo;
   private GenericRepositoryTest<MasterData> mastrData;

   public GenericRepositoryTest<User> UserRepo
           return this.usrRepo ?? new GenericRepositoryTest<User>(context);

   public GenericRepositoryTest<MasterData> MastrData
           return this.MastrData ?? new GenericRepositoryTest<MasterData>(context);

   private bool disposed = false;

   protected virtual void Dispose(bool disposing)
       if (!this.disposed)
           if (disposing)
       this.disposed = true;

   public void Dispose()


based on my repository and unit of work as it clear I have two repositories MasterData and and UserRepo,now in my controller I want to join these two,but I have no Idea why I get the error:Cannot evaluate expression because the current thread is in a stack overflow state

UnitOfWorkForTest _unitofWork=new UnitOfWorkForTest ();

        var listOfParks = (from s in _unitofWork.MastrData.Get()
                           join t in _unitofWork.UserRepo.Get()
                           on s.pv_person_resp_id equals t.user_id                                                           
                           select new SelectListItem
                               Text = t.user_name

I Have Two Controller Customer_Infocontroller and another Order_Infocontroller . Right Now I Am In Customer_Infocontroller . I Want To view Order_Infocontroller without Route Change . Only Use Link Tag How it Possible .Please Help Me

See I want to create a web application to read property of a class . So in order to do that I want to use reflection in MVC structure in VS2015. I will be using c#.

I call method:

 @using (Ajax.BeginForm("ControlleMethod", "ControllerName", new AjaxOptions()
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "partial-container",
            HttpMethod = "Post",
    <input type="submit" value="Method name"/>

In controller i want stop Ajax request to make replace, and redirect controller to reload whole page

public ActionResult AddPlaceManager(modelDto NewModel)
            if (ModelState.IsValid == false)
                return PartialView("Partial/_EditMethod", NewModel);
            if (ModelState.IsValid == True)
                return RedirectToAction("Index"); //Here i want to reload whole page

How can i do that?

Im trying to upload a big Datatable (140Mb) in a session and it throws the "Object not set to Instance of an Object" exeption. After a little research I noticed there is a size limit on a variable in a session. Is there anyway to modify that setting so I could upload the table?

How do I get a Facebook comment plugin comment count and send to another view in MVC

I can not use graph count share

<li class="firstsing"> <a href="#"><i class="fa fa-comments"> </i>{comment_count}&amp;id=https://localhost:26826/Home/standartposts/@item.ID Comments</a></li>
@*<li class="firstsing"> <a href="#"><i class="fa fa-comments"> </i> <span class="fb-comments-count" data-href="http://localhost:26826/Home/standartposts/@item.ID"></span> Comments</a></li>*@
   <div class="mask">
      <a href="@Url.Action("StandartPosts","Home")/@item.ID">
         <img src="~/img/@item.img" alt="">

I have an ASP.NET application where the user can add a record to the database by entering data in the edit window of a Devexpress Gridview. When saving the data a stored procedure is triggered that takes care of some additional functions. The issue is that most of the time this process runs smoothly, but every now and then a "value cannot be null.Parameter: fileOrServerOrConnection" is triggered. After some googleing I have found that this is most likely because the connectionstring can't be found, but I don't really understand why. The issue seems to occur totally random. First I thought that it might have to do with an expired Session, but it sometimes also occurs right after login... Further more, it only happens in the production environment and never in the identical UAT, or in the development environment. Since I don't really understand what is happening or why it might be happening I might have a hard time to explain the actual issue...

My question now is What is happening and how do I solve it. Tips on how I would be able to track more in detail where in my code it goes wrong in the production environment are also more than welcome!

I am struggling to sort out the following problem. I would appreciate any help and Thank you in advance.
Problem: My ConfirmEmail Action on Account Controller (Identity MVC C#), works fine, but if a user makes a mistake with a password and confirm the password, he receives an error message if he tries a second time. I've checked the error and when we try a second time the userId and code are null. here are my code:
My Controller Actions

// GET: /Account/ConfirmEmail
public async Task<ActionResult> ConfirmEmail(string userId, string code)

    if (userId == null || code == null)
        return View("Error");

    var confirmed = await UserManager.IsEmailConfirmedAsync(userId);
    if (confirmed)
        return RedirectToLocal(userId);

    var result = await UserManager.ConfirmEmailAsync(userId, code);
    if (result.Succeeded)
        ViewBag.userId = userId;
        ViewBag.code = code;

    return View(result.Succeeded ? "ConfirmEmail" : "Error");
public async Task<ActionResult> ConfirmEmail(SetPasswordBindingModel model, string userId, string code)
    if (userId == null || code == null) // this is where I get the Erorr (userId and code are null)
        return View("Error");
        // Don't reveal that the user does not exis


    if (!ModelState.IsValid)
        return View(model);

    var result = await UserManager.AddPasswordAsync(userId, model.NewPassword);
    if (result.Succeeded)
        var user = await UserManager.FindByIdAsync(userId);
        if (user != null)
            await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

        //    return RedirectToLocal(userId);  //This is the default return
        return RedirectToAction("ConfirmDetails", "Customers", new { id = TempData["UserId"] });  //I need to redirect to this page

    ViewBag.userId = userId;
    ViewBag.code = code;


    return View(model);

Can anyone help me? Thanks

I came upon this thought recently when I was working to add a 'dark/night' mode to my app.

Regularly in cellForRowAtIndexPath I would of course 'connect' my datasource to my newly created/reused cell.

Setting the cells data/strings/values etc, ready for display.

However, whilst cognisant of MVC, I myself, would sometimes set cell background colours or some other cell subview view related property (animations/colours/text style). - I'm working if this is truly a bad coding style?

During my work to create night mode, I moved ALL code related to view modification (colour/style/aesthetic) into each view class.

Then upon a reload of my tableView, I setup up each cell and finally call their new function to layout their aesthetics - which now lives inside the cell class.

Ergo, my cellForRowAtIndexPath has a single call to the cell instance to change its look and feel, and the rest of the code is purely setting data on the cell.

  • Is this the pure MVC approach?
  • Is this good practice?
  • Is it acceptable to be calling my tableView's reload method in order to trigger a call to update the cell as needed, whenever my viewController wants to change look and feel, or should I be keeping a reference to each cell separately?