I want to create a shopping cart, but i get this error. As you may see, i have the ShoppingCart class in the WebApplication1.App_Code namespace but when i try using WebApplication1.App_Code in the Default.aspx.cs, it does not work.

namespace WebApplication1.App_Code
{
    public class ShoppingCart
    {
        public List<CartItem> Items { get; private set; }

        public static readonly ShoppingCart Instance;

        static ShoppingCart()
        {
            if (HttpContext.Current.Session["ShoppingCart"] == null)
            {
                Instance = new ShoppingCart();
                Instance.Items = new List<CartItem>();
                HttpContext.Current.Session["ShoppingCart"] = Instance;
            }
            else
            {
                Instance = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
            }
        }
using System;
using System.Data;
using System.Linq;
using WebApplication1.App_Code;
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAddShoes_Click(object sender, EventArgs e)
        {
            ShoppingCart.Instance.AddItem(1);

            Response.Redirect("ViewCart.aspx");
        }

I'm trying to run this code from the ASP.Net code:

string strupdate = "Insert into registers(user, module, event_type)" +
    "values (" +
    "'" + user + "'," +
    "'" + event + "'," +
    "'" + source + "');";

/* connSQL it's the ODBC connection type: System.Data.Odbc.OdbcConnection */
connSQL.ExecuteNonQuery();

The query results into the following:

Insert into registers(user, module, event_type)values('user01','message','control');

Running this query from psql works perfectly fine, but running from the web returns the ODBC 07002 error with the following message: The # of binded parameters < the # of parameter markers

I'm having trouble figuring out how to create a DropDownList in my existing WebGrid. I'm retrieving the following data from my Controller:

List items 0-2 are filled with "KeyA":

enter image description here

And List items 3-5 are filled with "KeyOther":

enter image description here

These have not yet any combination with eachother but I'm trying to create a WebGrid with the list items of type "KeyA" on the first column presented in labels and the list items of type "KeyB" in the second column presented as DropDownLists for each list item of "KeyA". Look example:

enter image description here

I cant figure out how to do this, this is what I got now:

enter image description here

With the following code:

@{
                if (Model != null && Model.Count() > 0)
                {
                    var grid = new WebGrid(canPage: true, rowsPerPage: 10);
                    grid.Bind(source: Model, rowCount: 0, autoSortAndPage: false);

                    <div class="row" id="content2">
                        <div class="col-lg-12 d-flex align-items-stretch">

                            @grid.Table(tableStyle: "table table-responsive table-striped table-bordered",
                                columns: grid.Columns(
                                grid.Column(columnName: "KeyA", header: "KeysA", format:@<text><div class="" data-id="@item.KeyA" data-propertyname="KeyA">@item.KeyA</div></text>),
                                grid.Column(columnName: "KeyOther", header: "KeysOther", format:@<text><div class="" data-id="@item.KeyOther" data-propertyname="KeyB">@item.KeyOther</div></text>)
                                    ))
                        </div>
                        <!--Pagerlist for webgrid-->
                        <div class="col-lg-12 d-flex align-items-stretch">
                            @grid.PagerList(mode: WebGridPagerModes.All, paginationStyle: "pagination pagination-small pagination-right")
                        </div>

                        @Html.Hidden("dir", grid.SortDirection)
                        @Html.Hidden("col", grid.SortColumn)
                    </div>
                }
}

Hope somebody can help me!

Thanks in advance!

I am trying to change the default (20 minutes) timeout settings for my ASP.Net application (from timeout=20 to timeout=200). I have tried several things to get this to work, but I have not been entirely successful. I first tried adding the following to my web.config file: <sessionState timeout="200" cookieless="AutoDetect"></sessionState>. Then, I changed the settings in the Default Application pool: enter image description here

Finally, I tried setting the Session State timeout in the application in IIS. Is there something I am missing here? I suspect that there is some other overlooked setting (maybe from the Default Site settings in IIS) that is overridding something I've done here. Any suggestions? enter image description here

I have set up apache geode and I am using Pivotal.Gemfire.dll to set up the cache listener by extending CacheListenerAdapter.

Problem is, the below never fires when listening to the region with the correct key:

    public override void AfterCreate(EntryEvent<TKey, TVal> ev)
    {
        //code
    }

This does, however, work in a desktop application (Console.app/WinForms) but not in web application (MVC/WebForms)

If someone could help me or point me to the correct documentation page, I would really appreciate, it's been 3 days since I'm trying to get this to work.

I am looking at upgrading an existing ASP.NET MVC Web App from .NET Framework v4.5 to v.4.7.2. I was able to find some vague documentation from Microsoft, but there was nothing concrete in the docs https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/. For development I am using VS2019.

Is it recommended to go straight from .NET Framework 4.5 to 4.7.2 or would it be wiser to gradually migrate through the point releases 4.5.x, 4.6.x, etc. until I get to 4.7.2?

The application itself is pretty standard so I don't expect many surprises as I migrate, but I would like to know if there is a "correct" way to go about the migration.

I started with Blazor today while already having some experience in web-dev. However it seems that isn't enough. I want to get the eventarguments of an onkeydown event, so I can check for an enter-key-press.

I already tried to use a function in my event to check the keypress in a separate function, and already tried directly inserting something into the onkeydown event but nothing worked.

The following is the event I want to get the keypress from.

<input onkeydown="" bind="@todo.Title" />

I am using PushSharp library to send push notifications and notifications are working but I do not understand which URL WNS and APNS are using to send push notification . Can anybody help me to find what URL is actually hit to send push notification in case of WNS(PushSharp.Windows) and APNS(PushSharp.Apple).

Like GCM using following URL to send notification:

https://gcm-http.googleapis.com/gcm/send

I am looking for the URL that is being used by WNS and APNS to send push notification. Thanks.

the problem when I am trying to create a new query, it gives me a red error and says syntax error where is the first parenthesis { are and the INT values of (1,1) and (50) with NVARCHAR and also GETDATE() parenthesis and the ID ([ID] ASC)

CREATE TABLE [dbo].[Cart]
{

      [ID] INT IDENTITY (**1**,1) NOT NULL,
      [CLientID] NVARCHAR (**50**) NOT NULL,
      [ProductID] INT NOTNULL,
      [Amount] INT NOTNULL,
      [DatePurchased] DATETIME DEFAULT GETDATE**()**,
      [IsInCart] BIT NOTNULL,
      CONSTRAINT [PK_Purchase] PRIMARY KEY CLUSTERED ([**ID**] ASC)
}

I have a dynamically created action button within a method. I've assigned an ID to the button, but I need to open a modal when the button is clicked. I'll then need to pass the button ID to the modal in order to retrieve the data. How can I open a modal within this method?

private static List<Details> LoadData()
    {
        List<Details> infoObjs = new List<Details>();

            using (SqlConnection con = new SqlConnection(cs))
            {
                ...
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Details infoObj = new Details();
                    infoObj.CommentsID = rdr["COMMENT_ID"].ToString();
                    infoObj.Comments = rdr["COMMENT"].ToString();
                    infoObj.Status = rdr["STATUS"].ToString();
                    infoObj.Date = rdr["DATE"].ToString();

                    infoObj.Action = "<a class='btn btn-warning' ID=" + infoObj.CommentsID + "> <i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></a>";
                    //This button needs to open a modal.
                    infoObjs.Add(infoObj);
                }
            }
        return infoObjs;
    }

I have a VM spitting data from a db table into a datatable in my view. I have a delete button rigged, to where if the button in the requested col is selected, the rows for that data entry will be deleted. My delete button is being handled by an Ajax call to my controller function... however when I am debugging the controller, the param seems to contain all null data. Am I missing something here? I also have a button in a partial table above this one (not displayed) being handled the same way and this one has zero issues..

View:

<div class="row">
    <div class="col-md-12" style="overflow-y:scroll">
        <table class="table table-striped table-hover table-bordered" id="Terminals">
            <thead>
                <tr>
                    <th>@Html.DisplayNameFor(model => model.TerminalCommands.FirstOrDefault().TerminalID)</th>
                    <th>@Html.DisplayNameFor(model => model.TerminalCommands.FirstOrDefault().TerminalCommandLookup.Name)</th>
                    <th>@Html.DisplayNameFor(model => model.TerminalCommandValues.FirstOrDefault().Value)</th>
                    <th> </th>
                </tr>
            </thead>
            <tbody>

                @foreach (var item in Model.TerminalCommands)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.TerminalID, new { id = "deleteTerminalID", Value = item.TerminalID, @class = "form-control" })
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.TerminalCommandLookup.Name, new { id = "deleteCommand", Value = item.TerminalCommandLookup, @class = "form-control" })
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CommandValue, new { Class = "form-control", Value = item.CommandValue, Id = "deleteCmdValueValue" })
                        </td>
                        <td> 
                            <input id="btnDeleteTerminalCommand" type="submit" value="Delete" class="btn btn-danger">
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>

Javascript call:

  $(function () {
    $("#btnDeleteTerminalCommand").click((e) => {
        e.preventDefault();

        var data = {
            TerminalID: $("#deleteTerminalID").val(),
            CommandID: $("#deleteCommand").val(),
            CommandValue: $("#deleteCmdValueValue").val()
        };
        console.log("data");
        console.log(data);
        $.ajax({
             url: '@Url.Action("DeleteTerminalCommand", "TerminalCommand")',
            type: "POST",
            data: data,
            success: function (response) {
                console.log("Success");
                window.location.href = response.Url;
            }
        });
    });
});

VM:

public class AddTerminalCommandVM
{
    public string TerminalID { get; set; }

    public int CommandID { get; set; }

    public string CommandValue { get; set; }

}

Controller function:

        public ActionResult DeleteTerminalCommand(AddTerminalCommandVM removeCommand)
    {
        TerminalCommand removeTerminalCommand = new TerminalCommand();

        removeTerminalCommand.TerminalID = removeCommand.TerminalID;
        removeTerminalCommand.Command = removeCommand.CommandID;
        removeTerminalCommand.CommandValue = removeCommand.CommandValue;

        TCBL.DeleteTerminalCommand(removeTerminalCommand);

        var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "TerminalCommand");
        return Json(new { Url = redirectUrl });
    }

I have got error says:

System.InvalidOperationException: 'Cannot resolve scoped service 'tigerpaw.Models.AppDbContext' from root provider.'

I have absolute no idea what is going on as this is my first mvc project. Please let me know if more information is need. Any kind of help or suggestion are greatly appreciated. Thank you

My startup class

public class Startup
    {
        private IConfigurationRoot _configurationRoot;

        public Startup(IHostingEnvironment hostingEnvironment)
        {
            _configurationRoot = new ConfigurationBuilder()
                .SetBasePath(hostingEnvironment.ContentRootPath)
                .AddJsonFile("appsettings.json")
                .Build();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<AppDbContext>(options => options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));
            services.AddTransient<ICategoryRepository, CategoryRepository>();
            services.AddTransient<IToyRepository, ToyRepository>();
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseDeveloperExceptionPage(); //adding expection that's not in default
            app.UseStatusCodePages();// respon status code 400-600
            app.UseStaticFiles();// server static files
            app.UseMvcWithDefaultRoute(); //adding support for mvc

            DbInitializer.Seed(app);
        }
    }

Here is my Dbinitializer

public static void Seed(IApplicationBuilder applicationBuilder)
        {
            AppDbContext context = applicationBuilder.ApplicationServices.GetRequiredService<AppDbContext>();

            if (!context.Categories.Any())
            {
                context.Categories.AddRange(Categories.Select(c => c.Value));
            }
            if (!context.SmallToys.Any())
            {
                context.AddRange
                    (

                        new Toy { Name = "Mickey mouse", Price = 19.5M, ShortDescription = "12cm small size soft toy for any ages", Category = Categories["Small Size toys"], InStock = true, ImageUrl = "/Images/mickey-mouse-toy.jpg" },
                        new Toy { Name = "Teddy Bear", Price = 19.5M, ShortDescription = "14cm small size soft toy for any ages", Category = Categories["Small Size toys"], InStock = true, ImageUrl = "https://images-na.ssl-images-amazon.com/images/I/914blLD4RCL._SX425_.jpg" },
                        new Toy { Name = "Rabbit", Price = 19.5M, ShortDescription = "14cm small size soft toy for any ages", Category = Categories["Small Size toys"], InStock = true, ImageUrl = "https://images-na.ssl-images-amazon.com/images/I/31i4-mrHt6L._SX355_.jpg" }


                    );
            }
            context.SaveChanges();
        }

        private static Dictionary<string, Category> categories;
        public static Dictionary<string, Category> Categories
        {
            get
            {
                if (categories == null)
                {
                    var genresList = new Category[]
                    {
                        new Category { CategoryName = "Large Size toys"},
                        new Category { CategoryName = "Medium Size toys"},
                        new Category { CategoryName = "Small Size toys"}
                    };

                    categories = new Dictionary<string, Category>();

                    foreach (Category genre in genresList)
                    {
                        categories.Add(genre.CategoryName, genre);
                    }
                }

                return categories;
            }
        }

AppDbContext


    public class AppDbContext : DbContext
    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
        {

        }

        public DbSet<Category> Categories { get; set; }
        public DbSet<Toy> SmallToys { get; set; }
    }

the error that show up on my browser when i run it

An error occurred while starting the application.
InvalidOperationException: Cannot resolve scoped service 'tigerpaw.Models.AppDbContext' from root provider.
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)

InvalidOperationException: Cannot resolve scoped service 'tigerpaw.Models.AppDbContext' from root provider.
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
Microsoft.Extensions.DependencyInjection.ServiceProvider.Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceProviderEngineCallback.OnResolve(Type serviceType, IServiceScope scope)
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider provider)
tigerpaw.Models.DbInitializer.Seed(IApplicationBuilder applicationBuilder) in DbInitializer.cs
-
namespace tigerpaw.Models
{
    public class DbInitializer
    {
        public static void Seed(IApplicationBuilder applicationBuilder)
        {
            AppDbContext context = applicationBuilder.ApplicationServices.GetRequiredService<AppDbContext>(); // this line is in red
            if (!context.Categories.Any())
            {
                context.Categories.AddRange(Categories.Select(c => c.Value));
            }
            if (!context.SmallToys.Any())
tigerpaw.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in Startup.cs
-
        {
            app.UseDeveloperExceptionPage(); //adding expection that's not in default
            app.UseStatusCodePages();// respon status code 400-600
            app.UseStaticFiles();// server static files
            app.UseMvcWithDefaultRoute(); //adding support for mvc
            DbInitializer.Seed(app); // also this line is in red
        }
    }
}
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
Microsoft.AspNetCore.HostFilteringStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

In my solution I have a business layer containing some projects that target .NET Framework 4.7 (including EntityFramework data access layer and a lot of logic). Now I want to make a web application with .NET Core 2.2. I realise that .NET Core is not compatible with .NET Framework, but .NET Standard is compatible with both. Converting the business layer from .NET Framework to .NET Standard or .NET Core is not an option, as it is simply too much work.

My Question:

Is it possible to add a .NET Standard project in my business layer as a middleman, taking all the request from the .NET Core Web app and calling code (including accessing EF data) in my .NET Framework projects?

When i re-publish my project to my host, and try to display my view i get this error about 50% of the times depending on how lucky i am

Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

my view gets called by

    <div class="m-scene" id="main" style="margin-top: 1rem">
        <div class="m-header scene_element scene_element--fadein scene_element--delayed">
            <div class="containerTable">
                @Html.GetGridHtml(Model.Content, "table")
            </div>
        </div>
    </div>

and this is my method in the controller that should return my view

    public ActionResult Skader(LeBlenderValue data)
    {

        var jsonString = new WebClient { Encoding = System.Text.Encoding.UTF8 }.DownloadString("myStringHere");

        var dbObj = JsonConvert.DeserializeObject<List<SkaderModel>>(jsonString);

        var vm = new MonitorTableViewModel(){Skader = dbObj, gridData = data};
        return PartialView("~/Views/Partials/Monitor/Skader.cshtml", vm);
    }

The sitescope tool has the functionality for checking the Ping operation, with frequency of pinging the application configurable and email alerts as well.

Does Dynatrace support ping operation and email alerting ?

I want to logout the asp.net page using PHP curl, I've that .net page logout URL. Then i tried the below PHP code for logout.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $logoutUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
$curl_errno = curl_errno($ch);
if($curl_errno){
     echo $curl_errno;
}
curl_close($ch);

But it's not working, when i hit the logout URL in browser, the logout is working.

What is the best way to logout the .net page URL(https://hostname/logout.aspx) thanks in advance for you better support and idea

separately we can find no.of classes,methods and db's calls for each asp.net mvc project and angularJs project, I need to integrated with java code to find the asp.net mvc project and angularJs project.. Need code for it please someone suggest any logics to find it out

I have a Asp.net MVC controller class called OrdersController that has an HttpPost Action method called Create(). Then I have a View page called Create.cshtml that uses razor syntax and subscribes to the action event at the bottom of the razor page.

But whenever i press my button, nothing happens, nothing is sent to my server, no error, no loading, nothing.

Could someone take a look at my Create() Action method and my razor Create.cshtml page and tell me if I did something wrong or missed something please?

this is my create method

    // POST: Orders/Create
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(OrderViewModel collection)
        {
            try
            {
                var order = new Order()
                {
                    OrderTime = DateTime.Now
                };
                order.LocationId = collection.LocationId;
                order.CustomerId = collection.CustomerId;
                order.OrderTotal = 0;
                for (var i = 0; i < collection.Products.Count; i++)
                {
                    if (collection.Products[i].Checked)
                    {
                        order.OrderTotal += collection.Products[i].Price *      collection.AmountItems[i].QuantityBought;
                    }
                }
                order.Items = new List<OrderItem>();

                var orderItem = new OrderItem();

                //adding order items
                for(var i=0; i<collection.Products.Count;i++)
                {
                    if(collection.Products[i].Checked)
                    {
                        orderItem.QuantityBought =collection.AmountItems[i].QuantityBought;
                        orderItem.OrderItemNum = i;
                        orderItem.ProductId = collection.Products[i].ProductId;
                        orderItem.Price = collection.Products[i].Price;
                        order.OrderItems.Add(orderItem);
                    }
                }

                OrdRepo.AddOrder(order);
                foreach(var item in order.OrderItems)
                {
                    OrdRepo.AddOrderItem(item);
                }

                return RedirectToAction(nameof(Index));
            }

            catch
            {
               return View();
            }
        } 

below is my razor page, i subscribe to my Create event near the bottom of it

    @model HardwareStore.WebUI.Models.OrderViewModel
@{
    ViewData["Title"] = "Create";
}

<h1>Create Order</h1>
<form asp-action="Create">
    <div class="form-group">
        <label asp-for="LocationId" class="control-label">Location</label>
        <select asp-for="LocationId"
                asp-items="@(new SelectList(Model.Locations,"LocationId", "Name"))" class="form-control"></select>
    </div>
    <div class="form-group">
        <label asp-for="CustomerId" class="control-label">Customer</label>
        <select asp-for="CustomerId"
                asp-items="@(new SelectList(Model.Customers,"CustId", "FirstName"))" class="form-control"></select>
    </div>
    <div>
        @Html.LabelFor(model => model.Products)
        <br>
        @for (var i = 0; i < Model.Products.Count; i++)
        {
            @Html.HiddenFor(m => Model.Products[i].ProductId)
            @Html.HiddenFor(m => Model.Products[i].ProductName)
            @Html.HiddenFor(m => Model.Products[i].Description)
            @Html.HiddenFor(m => Model.Products[i].Price)
            @Html.CheckBoxFor(m => Model.Products[i].Checked)
            @:&nbsp;
            @Model.Products[i].ProductName
            @:&nbsp;
            @Html.EditorFor(m => Model.AmountItems[i].QuantityBought)
            @Html.HiddenFor(m => Model.AmountItems[i].OrderItemNum)
            <br />
        }
    </div>
    <div class="form-group">
        <input type="submit" value="Create" class="btn btn-primary" />
    </div>
</form>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

I'm currently working on a project where I want to display 2 webgrid tables with each different models. I've found alot of tutorials how to use multiple models in a regular MVC View but it does not work in a Razor View. I'm kinda stuck on this now.

What I've tried so far - 1

Controller:

I've tried using an dynamic ExpandObject to add two lists to this View, look code:

public ActionResult Index(int page = 1, string sortApi = "ApiName",string sortCompany = "CompanyName", string sortdir = "asc", string search = "")
{
        int pageSize = 13;
        int totalRecords = 0;
        if (page < 1)
        {
            page = 1;
        }
        int skip = (page * pageSize) - pageSize;
        ViewBag.TotalRows = totalRecords;
        ViewBag.search = search;

        //Dynamic ExpandObject
        var dataApiRedirects = getRedirects(search, sortApi, sortdir, skip, pageSize, out totalRecords);
        var dataCompanies = getCompanies(search, sortCompany, sortdir, skip, pageSize, out totalRecords);
        dynamic mymodel = new ExpandoObject();
        mymodel.ApiList = dataApiRedirects;
        mymodel.CompanyList = dataCompanies;

        return View(mymodel);
}

View:

<div class="col-sm-1 d-flex align-items-stretch" style="padding-top: 5%;">
                <div class="form-group">
                    <a href="#" class="btn btn-primary" data-toggle="modal" data-target="#myModal">+API</a>
                </div>
                <!--MODAL-->
                <div class="modal fade" id="myModal" >
                    <div class="modal-dialog" style="width: 20%;">
                        <div class="modal-content">
                            <div class="modal-header">
                                <a href="#" class="close" data-dismiss="modal">&times;</a>
                                <h3 class="modal-title">Add API</h3>
                            </div>
                            <div class="modal-body">
                                <form id="myForm">
                                    <p>@Html.TextBoxFor(Model.ApiList.ApiName, new { @class = "form-control", @placeholder = "Name" })</p>
                                    <p>@Html.TextBoxFor(model => model.ApiList.First().Company.CompanyName, new { @class = "form-control", @placeholder = "Company" })</p>
                                    <p>@Html.TextBoxFor(model => model.ApiList.First().ApiURL2, new { @class = "form-control", @placeholder = "URL" })</p>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
                                <input type="reset" value="Submit" class="btn btn-success" id="btnSubmit" />
                            </div>
                        </div>
                    </div>
                </div>
 </div>

However when I want to create textboxes in my modal im getting the following error:

enter image description here

What I've tried so far - 2

I've also tried using a ViewBag:

Controller code:

public ActionResult Index(int page = 1, string sortApi = "ApiName",string sortCompany = "CompanyName", string sortdir = "asc", string search = "")
{
        int pageSize = 13;
        int totalRecords = 0;
        if (page < 1)
        {
            page = 1;
        }
        int skip = (page * pageSize) - pageSize;

        var dataApiRedirects = getRedirects(search, sortApi, sortdir, skip, pageSize, out totalRecords);
        var dataCompanies = getCompanies(search, sortCompany, sortdir, skip, pageSize, out totalRecords);
        dynamic mymodel = new ExpandoObject();
        mymodel.ApiList = dataApiRedirects;
        mymodel.CompanyList = dataCompanies;

        //Model 1 data
        ViewBag.CompaniesList = dataCompanies;


        ViewBag.TotalRows = totalRecords;
        ViewBag.search = search;

        //Model 2 data
        return View(mymodel);
}

HTML Code:

var getlist = ViewBag.CompaniesList as IEnumerable<APIBrokerFrontend.Models.Company>;

<div class="modal fade" id="myModalCompany">
                <div class="modal-dialog" style="width: 20%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <a href="#" class="close" data-dismiss="modal">&times;</a>
                            <h3 class="modal-title">Add Company</h3>
                        </div>
                        <div class="modal-body">
                            <form id="myForm">
                                @<p>@Html.TextBoxFor(getlist.First().CompanyName, new { @class = "form-control", @placeholder = "Company Name" })</p>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
                            <input type="reset" value="Submit" class="btn btn-success" id="btnSubmit" />
                        </div>
                    </div>
                </div>
</div>

Using ViewBag I'm getting the following error:

enter image description here

Does anyone have a solution for this?

Thanks in advance!

I just want to create an insert form link with sql server in c# webforms. Unfortunately, i got this error and don't get the idea to define them.

Error CS1061 'HtmlGenericControl' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'HtmlGenericControl' could be found (are you missing a using directive or an assembly reference?)

please help me to define 'Text' in the right way.

this is my Contact.aspx:

 <form id="form1" runat="server">  
<div id="title">  
<h1>REGISTER PAGE</h1>  
</div>  
    <div id ="teble"></div>  
<table class="auto-style1">  
    <tr>  
        <td>  
            <aspLabel ID="Label1" runat="server" Text="name"></aspLabel></td>  
        <td>  
            <aspTextBox ID="TextBox1" runat="server"></aspTextBox></td>  
    </tr>  
    <tr>  
        <td>  
            <aspLabel ID="Label2" runat="server" Text="email"></aspLabel></td>  
        <td>  
            <aspTextBox ID="TextBox2" runat="server"></aspTextBox></td>  
    </tr>  
    <tr>  
        <td>  
            <aspLabel ID="Label3" runat="server" Text="subject"></aspLabel></td>  
        <td>  
            <aspTextBox ID="TextBox3" runat="server"></aspTextBox></td>  
    </tr>  

</table>  
<div id="button">  
    <aspButton ID="Button1" runat="server" Text="submit" OnClick="Button1_Click" BackColor="Yellow" />  
</div>  
    <div id="sim"></div>
  <p>
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Table]"></asp:SqlDataSource>
    </p>

this is my Contact.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Contact : Page
{
protected void Page_Load(object sender, EventArgs e)
    {
    if (IsPostBack)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        conn.Open();
        string checkuser = "select count(*) from Contact where name='" + TextBox1.Text + "'";
        SqlCommand cmd = new SqlCommand(checkuser, conn);
        int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString());

        if (temp == 1)
        {
            Response.Write("Student Already Exist");
        }

        conn.Close();
    }
 }
protected void Button1_Click(object sender, EventArgs e)
{
   try
    {
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        conn.Open();
        string insertQuery = "insert into Table(Name,Email,Subject)values (@name,@email,@subject)";
        SqlCommand cmd = new SqlCommand(insertQuery, conn);
        cmd.Parameters.AddWithValue("@name", TextBox1.Text);
        cmd.Parameters.AddWithValue("@email", TextBox2.Text);
        cmd.Parameters.AddWithValue("@subject", TextBox3.Text);

        cmd.ExecuteNonQuery();

        Response.Write("Student registeration Successfully!!!thank you");

        conn.Close();

    }
    catch (Exception ex)
    {
        Response.Write("error" + ex.ToString());
    }
}  
    }



I have textbox like below in ASP.net ascx page

< input type="text" maxlength="200" runat="server" id="txt_OTP" / >

I want to get textbox input value in jquery (in same ascx page) but .value or .text function is not available

jquery code: document.getElementById('OTPvalidation1_txt_OTP').Value

**here ID is correct but .Value or .text function is not available in ascx page. Is there any alternative keyword for this in ascx page????