We help IT Professionals succeed at work.

ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Hi Experts!

How do you update the Input element to accept multiple files?

This is in the view:
@Html.TextBoxFor(Model => Model.Something, new { @type = "file",@id= "js-spec-file_", @class = "js-spec-file form-control", @accept = ".pdf, .doc, .docx, .jpg, .jpeg, .png"})

Open in new window

This is what's returned from the browser:
<input accept=".pdf, .doc, .docx, .jpg, .jpeg, .png" class="js-spec-file form-control" id="js-spec-file_0" name="Something" type="file" value="">

Open in new window

To update the input to accept multiple files we'll need to add "multiple" to the Input as in the example:
https://www.w3schools.com/tags/att_input_multiple.asp
<form action="/action_page.php">
  <label for="files">Select files:</label>
  <input type="file" id="files" name="files" multiple><br><br>
  <input type="submit">
</form>

Open in new window

Have tried adding the word "multiple" and it would fail:
@Html.TextBoxFor(Model => Model.Specialty.Something, new { @type = "file",@id= "js-spec-file_", @class = "js-spec-file form-control", @accept = ".pdf, .doc, .docx, .jpg, .jpeg, .png", "multiple" })

Open in new window

error
TIA
0
Hi,

I need to convert this html file attached to classic asp. Please advise how I go about doing so. Thankyou.
sample.txt
0
Hi,

I am parsing an XML file but as this breaks there is no clear way to see at which record this fails, hence I have added a console log each value such as:


   Dim sqlConn = New SqlConnection(ConfigurationManager.ConnectionStrings("ProjectConnectionString").ToString)
        Try
            Dim ds As DataSet = New DataSet()
            ds.ReadXml(Server.MapPath("~/SampleData.xml"))
            Dim dt As DataTable = New DataTable
            'dt.Columns.Add("IDNumber", GetType(Integer))
            dt.Columns.Add("code", GetType(Integer))
            dt.Columns.Add("stage", GetType(String))
            dt.Columns.Add("systemplantreference", GetType(String))
            dt.Columns.Add("equipmentdescription", GetType(String))
            dt.Columns.Add("[level]", GetType(String))
            dt.Columns.Add("location", GetType(String))
            dt.Columns.Add("detailsnotes", GetType(String))
            dt.Columns.Add("duration", GetType(Integer))
            dt.Columns.Add("targetreportdate", GetType(Integer))
            dt.Columns.Add("progress", GetType(Integer))
            dt.Columns.Add("reporteddate", GetType(DateTime))
            dt.Columns.Add("start", GetType(DateTime))
            dt.Columns.Add("[end]", GetType(DateTime))

            Dim dr As DataRow
            For Each _dr As DataRow In ds.Tables(0).Rows
                dr = dt.NewRow

                'dr("IDNumber") = _dr(0)
                'Page.Response.Write("<script>console.log('IDNUMBER: 

Open in new window

0
I have a side project in Web Forms that I want to upgrade to .Net Core and Angular on my own time.  I'm using VS 2019.

1. I'm following this example   https://www.c-sharpcorner.com/article/create-angular-8-application-with-asp-net-core-3-0/

2. I installed npm

3. Installed Angular 9. I see this

ee1.png
4. I created the project. Looking at package.json...why do I see Angular 8? I see this. Is this OK?
ee2.png
0
I am diving into MVC and hit a snag.

In my home controller I am populating a ViewBag. Then I am trying to put that into a drop down list

Home controller:

 
string _connectionString = WebConfigurationManager.ConnectionStrings["xxxxxxx"].ToString();

            using (SqlConnection con = new SqlConnection(_connectionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //

            
                SqlDataAdapter _da = new SqlDataAdapter("Select Name from AspNetRoles", con);
                DataTable _dt = new DataTable();


                _da.Fill(_dt);
                
                ViewBag.RoleList = new SelectList(_dt.AsEnumerable());

                
                con.Close();
                
            }

Open in new window


Index.html :
 
@Html.DropDownList("Name", (IEnumerable<SelectListItem>)ViewBag.RoleList, "Select an application", "Name")

Open in new window



My dropdown populates the correct number of rows, however the proper text does not come up=> system.data.datarow is there 6 times

I am sure I am not converting something....can you help me with this easy newbie question?
0
Hello all:

I have a old asp.net web form application I have been tasked to maintain.  I have a Site.Master page that I've added some server controls on.  This page mainly hold a menu bar with links to various other pages. When someone clicks on a link in a specific section of the menu, they are directed to a sub-folder containing other pages.  These pages are not linked to the master page.

So my issue is on these pages that are not linked, I have an asp:label control that I am trying to populate via ConfigurationManager.AppSettings.  The problem is when the page renders, nothing is showing up, not even the span that would've been created with the asp:label.

The purpose of this control is to display what environment the user is in.  I have it on the Site.Master and it works well, but on the individual page that is not associated with the Site.Master, it does not show up.

on Site.Master:
<asp:Label ID="EnvironmentDescr" runat="server" CssClass="environmentDesc" Text="<%$ AppSettings: EnvironmentDescription %>" />

on individual page:
<asp:Label ID="EnvironmentDescrDO20" runat="server" CssClass="environmentDesc" Text="<%$ AppSettings: EnvironmentDescription %>" />

Can someone please let me know what I am doing wrong?  I have other asp:label controls on the individual page and they're all working.

Many thanks for your assistance!

Juan
0
Hi,

I am working on C#, ASP.net application.


I am getting IQueryable<byte[]> from the query.
I need byte[] bytes to pass into the method Read to get the real document.

Please advise the solution


IQueryable<byte[]> AWBFile = from x in repository.Select() where x.OrderCode == ordercode && x.TrackingNumber == trackingNumber select x.AWBimagefile;

byte[] bytes = AWBFile //  Get bytes[] from here
docFromUrl.Read(bytes);

Open in new window


Thanks
0
Could someone please tell me how I can resolve this error? This error that I've been receiving from my Production environment does not tell me exactly where or what page in my ASP.NET web app causes the error:

Invalid URI: The hostname could not be parsed.

at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Web.Util.UriUtil.BuildUriImpl(String scheme, String serverName, String port, String path, String queryString, Boolean useLegacyRequestUrlGeneration)
at System.Web.HttpRequest.BuildUrl(Func`1 pathAccessor)
at System.Web.HttpRequest.get_Url()
at System.Web.Http.WebHost.HttpControllerHandler.ConvertRequest(HttpContextBase httpContextBase, IHostBufferPolicySelector policySelector)
at System.Web.Http.WebHost.Routing.HttpContextBaseExtensions.GetOrCreateHttpRequestMessage(HttpContextBase context)
at System.Web.Http.WebHost.Routing.HttpRouteExceptionHandler.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Open in new window


Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36


Many thanks in advance.
0
public int Calculator(int fristno, int secondno)
        {
            return(fristno + secondno);
        }

this will give int as an element tag. how do I customized that?
0
I am designing an api, which will be called from my front end. say I have a controller method  that calls some other third party api process results and returns json response to the front end ( see sample code below) .

if there is an error in the reques/response and the request is unsucessful to the 3rd party apis, what is best approach. should I return empty json response to the front end , after handling and logging exceptions.

or is it better to send some message so that it can be dealt on the front end. if so can someone share some sample code for this. ?

//get method in some controller
public ActionResult GetData()
{
try
    //call other apis
    //if the response is successful
           return data;
    //if unsucessful
          // ?? what to return to the front end ??
catch
      //log exceptions    
}

front end code ----------------------------------------

$(document).ready(function () {
            $.ajax({
                type: "GET",
                url: "//somecontroller//GetMethod",
                data: param = "",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: successFunc,
                error: errorFunc
            });

            function successFunc(data, status) {    
                           //process json data
            }

            function errorFunc() {
                         //do something
            }
       …
0
Dear Experts
Based on the business processes we have identified solution development to be done in .NET Core framework with  Visual Studio using C# and MSSQL we have decided power BI for reporting and analytics( on-premise power BI report server) but customer have asked if possible to consider PostgreSQL, please help to understand on following
1.Application developing using .NET Core framework with Visual Studio using C# instead of MSSQL for database going for PostgreSQL will there be any complications, limitations and some thing that we have to comprise.
2.If we chose PostgreSQL as database server and front end application .NET Core framework with Visual Studio using C# and develop application but using power BI for reporting and analytics is there going to be any challenges, does power BI has connector to interface with PostgreSQL please let us know ,
Please help on above 1 and 2
0
Hello All:

I have a classic web forms asp (vb) web application that I am working with.  I have one page that I would like to embed a value from my web.config's app.settings.  this page references an external js file.  What I am ultimately trying to do is pass the value from app.settings to the js file on an onclick event.  The app.settings key holds the value of the current server, so I have transforms set to update the web.config with the correct server name when the application runs.

So in my app.settings I have:
<add key="CurrentServer" value="ProductionServer"/>

What I was trying to do was something like this:
<input type="hidden" id ="CurrentServer" value="<%$ AppSettings: CurrentServer %>" />

My reasoning behind this approach is then in the external file, I could target this input by doing something like:

let currentServer = document.getElementById('CurrentServer').value

When I run the page, I receive the following error:
Literal expressions like '<%$ AppSettings: CurrentServer %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ AppSettings: CurrentServer%>" /> instead.

Can someone please steer me in the right direction?  Would a server control be more appropriate?  If so, how would I interrogate the rendered control using JavaScript once the onclick even is fired that triggers the javascript code?

Many thanks for any assistance!

Juan
0
Hi,

How can I make a string from database as a link?

<asp:HyperLink ID="SponsorWebsiteURL" NavigateUrl="XXXXX" runat="server">link</asp:HyperLink>

This is what I use in the page, what is the code to use in code-behind? thank you very much
0
Hi. I have been asked to put a header tag in the ASP.net whose markup is shown below
Part of the tag is shown in the first code piece below and the markup for the page is shown in the second code piece
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GN');</script>
<!-- End Google Tag Manager -->

Open in new window


<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="Office2Web._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

	<section class="p-0">
		<div id="homeCarousel" class="carousel slide" data-ride="carousel">
			<!-- Indicators -->
			<ol class="carousel-indicators">
				<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
				<li data-target="#myCarousel" data-slide-to="1"></li>
				<li data-target="#myCarousel" data-slide-to="2"></li>
			</ol>

			<!-- Wrapper for slides -->
			<div class="carousel-inner">
				<div class="item active">
					<div class="carousel-content">
						<div class="container h-100">
							<div class="row h-100">
								<div class="col-md-6 h-100">
									<h1>Widen your horizons. 

Open in new window

0
HttpContext.Current is null after calling ConfigureAwait(false) in ASP.NET MVC using C#.  How do I resolve this problem.?

Please provide code fix.

Many thanks in advance.
0
C#.MVC What Controller for MP3 Upload Web Service?

I need a web service that accepts an MP3 file and kicks off a series of steps. So, what is the best type of Controller object to use?

And what kinds of configurations will be best for this? Does this require configurations available only through WCF?

Thanks
0
I have a Windows 2016 RDS farm.  In Windows 2012r2 RDS, there was documentation on how to remove the domain name requirement.

So far I have not been able to find in any of the blogs such as RDS Gurus or nedimmehic.org or even on MS forums.

Does anyone know how to remove this in Server 2016?
0
I have a cache object in C# that still has not expired yet, and I want to update the value of its key. How do I do that? This is for an ASP.NET MVC web app.  For example:

UserLogin userLogin = new UserLogin() {
  LoginAttempts = 1,
  DateTimeAttempted = DateTime.Now
};

if (System.Web.HttpContext.Current.Cache["LoginInfo"] == null)
{
   System.Web.HttpContext.Current.Cache.Insert("LoginInfo", userLogin, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero);
}

if (System.Web.HttpContext.Current.Cache["LoginInfo"] != null && UserAuthenticationFailedAgain)
{
   userLogin.LoginAttempts = 2;
   userLogin.DateTimeAttempted = DateTime.Now;
   // Now how do I update the value of this existing cache object's key "LoginInfo" so that the when I access Cache["LoginInfo"].LoginAttempts and Cache["LoginInfo"]. DateTimeAttempted, I get 2 and an updated date time, respectively??  I don't see System.Web.HttpContext.Current.Cache.Update() in docs.microsoft.com
}


Many thanks in advance.
0
Hi
In my ASP.net Site Master whose markup code is shown below I have the following button
     <button class="btn btn-primary" ID="btnGetStarted">Get started</button>
I want to run VB.net code behind this but when I double click on it it does not create a VB.net click event



<%@ Master Language="VB" AutoEventWireup="true" CodeBehind="Site.master.vb" Inherits="Office2Web.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> Office2Web Microsoft Office and Web Solutions</title>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>

    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,700&display=swap" rel="stylesheet">
</head>
<body>
    <form runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
              …
0
Hi

In ASP.net I have a web form where the user can fill out their email address and some other details then hit a button that sends me an enquiry. I usually just use VB.net code to send an email to me. Unfortunately the emailing isn't work properly so was looking for other ways to be notified of the enquiry. Is there something that I can build in or perhaps a service that I can use? Any suggestions would be welcome.

Thanks
Murray
0
I have a form on web application, I load the field values on the form and click the save button and it doesn't save the record on the database at first click but if I press the button again it saves it. I put the breakpoint on my Page_Load()event and tried debugging it so what happens is as I run the application, Page_Load() gets executed populates the data on the grid. Now, if I enter field values and click save, it again goes to Page_Load() event but it doesn't go to button_save() event. But if I click it again then it goes to Page_Load() and then goes to button_Save() and saves the record.

I want to click the mouse button once and save the record, how could I be able to do that? I am using VB.NET. Thank you.
0
IIS and ASP.net problem.

I have an application that I recently moved from Windows Server 2008 to Windows Server 2019.

Some of the data being saved contains </=, which produces an error: A potentially dangerous Request.Form value was detected from the client

My page header contains:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WaferRFP.aspx.vb" Inherits="Wafers_WaferRFP" ValidateRequest="false" %>

I have also tried adding:
<pages validateRequest="false"></pages>
to the System.web section of the Web.config file, but I am still getting the error message.

What am I missing?
0
I cannot see the issue in the code below.

            XmlDocument response1 =
               dataAccess.DBConnectors.Calls.FindCorrespondence(
                  new DataLayer.DBConnectors.Requests.FindCorrespondenceRequest()
                  {
                      maxRows = "20",
                      correspondenceSearchCriteria = new DataLayer.DBConnectors.Requests.FindCorrespondenceRequest.CorrespondenceSearchCriteria()
                      {
                          startDate = "2000-01-01"
                      }
                  }
               );

Open in new window

0
using Java script

I am trying to remove all contents of RadioButtonList and refill it with another items
is there away

I appreciate it if someone helps
0
Hi

I want to learn how to use Microsoft Power Apps. I code Excel and Access solutions in VBA and VSTO
and ASP.net web solutions in VB.net. Where will I find parallels and tutorials?

Thanks
0

ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications