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

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi

I have an ASP.net website that I built in Visual Studio 2017. Can I control which .net framework it is published in?
My hosting company only supports up to 4.5

Thanks
0
I have one issue in this line of code.
I am getting one extra record which has CPP as false and CPPExpires as '2020-10-10'

Now based on the where condition I should not get this record but now sure why I am getting this record from the below condition

   lblTotalClipCustomer.Text = accounts.Where(x => x.CPP == true && x.CPPExpires >= DateTime.Today).Count().ToString();

Open in new window

0
I'm very new to MVC5 using razor. I've been able to stumble through some problems but I'm stuck now. Here's what I need to do:

  • Move items from one listbox control to another listbox control
  • Access/get the items from both list boxes at some point in time for processing

my model contains the following:

        public IEnumerable<SelectListItem> AllAvailableServices { get; set; }

        public IEnumerable<string> AllAvailableSelectedServices { get; set; }

		public IEnumerable<SelectListItem> AddedServices { get; set; }

		public IEnumerable<string> AddedSelectedServices { get; set; }

Open in new window


my view contains the following. I would like to access the items in the AddedServices list when the user clicks the "Submit" button

@using (Html.BeginForm("Category", "Manager", FormMethod.Post))
{
    <table class="contain">
        <tr>
            <td>
                <table class="nav">
                    <tr class="nav">
                        <td class="navLeft">
                            <input type="submit" value="Submit" name="btnSaveCategory" class="button" onclick="location.href = '@Url.Action("UpdateCategoryAndServices")'"/>
                            <input type="button" value="Back" name="btnBack" class="button" onclick="location.href = '@Url.Action("Back")'"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
.
.
.
            

Open in new window

0
I am trying to publish my app via vs2013, but the publishing errors
on my master pages. Can someone tell me what is missing.
The app runs perfectly when I run it locally

The following are the errors:
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/7200.master(1,0): Error ASPPARSE: The file '/master/7200.master.cs' does not exist.
/master/common.master(1,0): Error ASPPARSE: The file '/master/common.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.
/master/720.master(1,0): Error ASPPARSE: The file '/master/720.master.cs' does not exist.

See Attached.  Down to the wire.

Isaac

partial class master_720 : 

Open in new window

0
This line of code should bring back 1 but I don't know why it's bringing back 2

frm.MultiValue.ActiveButtonCount = Convert.ToInt32(rd["ActiveButtonCount"] ?? 2);

Open in new window


I see the value is 1.
ee1.png
but it comes out as 2

ee2.png
0
In SQL Server management studio, I have a table called, Common.
Common has a column called, FLSA.
The FLSA column can only have one of two values entered:
1. Exempt
2. Non-Exempt
If I use a Check Constraint, then it will be more difficult for my Asp.Net web application's Entity Framework to pull the choices when I want to populate a drop down list in the HTML.
If I use a reference table called FLSA, do I add those two values directly and then create a relationship between the Common table and the FLSA table; OR do I use a check constraint on the FLSA table?
If I add the two values directly to the FLSA table, do I need a separate primary key field like Flsa_Id OR can I just make the FLSA column itself the primary key?
If I make the FLSA column of the FLSA table the primary key, how do I prevent any application from adding more values. There should only be those two values unless I manually change it through SSMS.
0
Hello,
I am trying to build a microservice with MVC connecting to MySQL . Any suggestions on how to go about.
Thanks
0
My AutoIt script downloads   http://www.xxx.thedomain.org/zzz/Default.aspx once a week.
The script aborts 1 out of every 20 times due to a random "404 " error from thedomain.org.   (Its an old government website so it is unlikely to always give random errors.)

I have already tested a workaround by using several garbage URLs, but I would prefer to have a url that generates a "404 file or directory not found error".

Can anybody give me such a URL?
 
rberke
By the way, my workaround is to wait 20 minutes the retry the URL.
0
We currently use ASPUpload and DropZonejs  to drag and drop files and then upload them to our server.

We are looking for a compatible script that will ZIP (compress) the files after the user drags and drops them in the "DropZone", and create one zip file which is the one that would be uploaded using ASPUpload.
Any recommendations on a script that would do this?

We need this for ASP Classic and also for NetCore.
0
I have an ASP.Net webforms app with a GridView.  (The Gridview automatically generates the columns on binding because the data source is dynamic and the number of columns vary.)

I have code in place so when a cell in the GridView is clicked by the user it will display some data relative to the clicked cell in a Panel via the ModalPopupExtender control (from AJAX control toolkit).

The problem I have is the ModalPopupExtender fires BEFORE the GridView_RowCommand.   I need to run a query in the GridView_RowCommand event to collect the data to populate the labels in the Panel control, that is displayed via the ModalPopupExtender.   The query needs to run in the GridView_RowCommand event because this is where I get the needed Row and Cell index data for the query.

How do I get the ModalPopupExtender to fire AFTER the GridView_RowCommand event?

ASPX code (Pertinent):

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


    <style type="text/css">

   .modalBackground

    {

        background-color: Black;
        filter: alpha(opacity=90);
        opacity: 0.8;

    }

    .modalPopup

    {

        background-color: #FFFFFF;
        border-width: 3px;
        border-style: solid;
        border-color: black;
        padding-top: 10px;
        padding-left: 10px;
        width: 300px;
        height: 140px;

    }

        </style>


                        <asp:GridView ID="grdKanban" runat="server" 

Open in new window

0
I have to restrict spacebar on my textbox I restrict keyvode 32 using JavaScript and it's working fine on desktop but on mobile devices it doesn't works. Can anyone provide perfect solution for this?
0
Hi,

I found this code to compile and execute code in runtime:

 Dim entrada As String

        Try

            entrada = My.Computer.FileSystem.ReadAllText("Codigo1.txt")
        Catch ex As Exception
            MessageBox.Show(" Erro : " + ex.Message)
            Return
        End Try



        Dim codigo = <code>
                       Imports System
                       Imports System.Windows.Forms

                       Public Class TempClass
                           Public Sub ResultadoTexto(ByVal txtOutput As TextBox)
                               <%= entrada %>
                           End Sub
                       End Class
                   </code>
        MsgBox(codigo)

        Try

            Dim vbProv = New VBCodeProvider()

            Dim vbParams = New CompilerParameters()

            vbParams.ReferencedAssemblies.Add("mscorlib.dll")
            vbParams.ReferencedAssemblies.Add("System.dll")
            vbParams.ReferencedAssemblies.Add("System.Windows.Forms.dll")
            vbParams.GenerateExecutable = False

            vbParams.GenerateInMemory = True

            Dim resultadoCompilacao = vbProv.CompileAssemblyFromSource(vbParams, codigo.Value)

            If resultadoCompilacao.Errors.Count > 0 Then

                For Each er In resultadoCompilacao.Errors
                    MessageBox.Show(er.ToString())
                Next
            Else

                Dim obj As Object = 

Open in new window

0
I'm trying to use Impersonation to delete files by connecting to an NetWare server. The code below works when I run it from C# code behind but I need to hide the password\username. I tried Impersonation, but I get denied returned.
What is the best way to run net use command from my code?

var  cn = "net use " + ServerPath + " " + ServerPassword + " /user:" + ServerUsername;
0
Having a problem retrieving information from an API.  I keep getting an (403) Forbidden error.

public string GetJsonString(string url)
        {

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            

            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, System.Text.Encoding.UTF8);
                    return reader.ReadToEnd();
                }
            }
            catch (WebException e)
            {
                WebResponse errorResponse = e.Response;
                using (Stream responseStream = errorResponse.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, System.Text.Encoding.GetEncoding("utf-8"));
                    string errorText = reader.ReadToEnd();
                }

                throw;
            }
        }

Open in new window


URL: https://api.weather.gov/points/29.146673,-80.964371

I can't figure out why this API is causing an error.
0
Hi Experts,

We just changed the look and feel of our website. But when user first load it, they see the old design and after they clear the cache, they can see the new one. Any suggestion how long it will take to update on their side if they don't clear the cache.

Please suggest!!
0
Hi

I am getting a Compilation Error in the following code in my ASP.net wen form. The JavaScript shown further down runs fine in the button click shown
in the second piece of code

  <asp:RadioButton ID="RadioButtonSimple" OnCheckedChanged="showLoading();"  runat="server" AutoPostBack="True" Checked="True" 

Open in new window


                              <asp:Button ID="btnClear" runat="server" BackColor="White" CssClass="roundedCornerBigButton" ForeColor="#000066" Text="Clear" Width="200px" OnClientClick="showLoading();" />

Open in new window


   	<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script type="text/javascript">
		//<![CDATA[
	    function showLoading() {
	        $('.pleaseWait').show();
	    }
		//]]>
       </script>

Open in new window

0
I am trying to write code that will determine the resolution of the screen the user is using in order to properly size charts.  I am having trouble getting anything to work. Can someone please help? I am using ASP.Net chart control and vb.net.

Following is code that does not work.

Thanks for the help.

Dim CurScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim CurScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim DesignWidth As Integer = 1680        
Dim DesignHeight As Integer = 1050 
        Dim WidthRatio As Single
        Dim HeightRatio As Single

        WidthRatio = CurScreenWidth / DesignWidth
        HeightRatio = CurScreenHeight / DesignHeight

        Dim ChartWidth As Single = DesignWidth * WidthRatio * 0.96         
Dim ChartHeight As Single = DesignHeight * HeightRatio * 0.85

Open in new window

0
I have the following class in a file called classfleet.cs

public class Fleet
{
        
        public string Make { get; set; }
        public string Model { get; set; }
}

Open in new window


on the aspx webpage, I want to get like below.

<asp:textbox text="Make" />
<asp:textbox text="Model" />

All I want is to get the class child name. not the value.
Is it possible with c#? Please show me how if it is possible.
0
FindControl is throwing a null reference exception.  I have to reference a list column which contains
the control id's to match in page but my query does not work using FindControl with the column/field name which contains the
name of the control.  I tried creating a struct but still throws exception. I what I am trying to do posible and how. Can someone help?

Thanks in advance,
Isaac

<div class="form-group" visible="false" id="FirstName" runat="server">
                  <div class="col-xs-12 col-md-8 col-sm-10 nill">
					<asp:Label ID="lblFirstName" runat="server" AssociatedControlID="txtFirstName" Text="First name *" CssClass="control-label" />
                      <br />
					<asp:TextBox ID="txtFirstName" runat="server" CssClass="form-control" MaxLength="50" aria-label="First name" required="required" AutoPostBack="true"></asp:TextBox>
					<span class="required"></span>
                  </div>
                </div>
                     <br />
                </td>
            <td>
//////////////////////////////////////
struct providerList {
                    public int fieldId;
                   public string fieldRequired;
                   public string aspName;
                   public string aspType;
                           }
private void loadform(List<ProviderInRequest> providerList)
        {

            for (int i = 0; i < providerList.Count; i++)
            
        
            {

                 
                Control ctrl = 

Open in new window

0
Hi. I have an ASP.net page. The markup is shown below.
How would I trap an error caused by the JavaScript
and show the error I a Response.Write sort of way?

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

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

  	<div>

	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.slider1 img:gt(0)').hide();
            setInterval(function () { $('.slider1 :first-child').fadeOut(2000).next('img').fadeIn(2000).end().appendTo('.slider1'); }, 7000); /*7 sec*/

            $('.slider2 img:gt(0)').hide();
            setInterval(function () { $('.slider2 :first-child').fadeOut(2000).next('img').fadeIn(2000).end().appendTo('.slider2'); }, 5000); /*9 sec*/

            $('.slider3 img:gt(0)').hide();
            setInterval(function () { $('.slider3 :first-child').fadeOut(2000).next('img').fadeIn(2000).end().appendTo('.slider3'); }, 6000); /*11 sec*/
        });
			</script>
			<style type="text/css">

table td{
border:none;
}
div.columns {width:1260px}
div.columns div   { height:650px; width:420px; float: left; }
div.slider1 img { position:absolute; }
div.slider2 img { position:absolute; }
div.slider3 img { position:absolute; }
div.clear         { clear: 

Open in new window

0
I am working on an asp.net c# web application that creates a report and saves the report as a pdf. The report could reach up to 140 pages and is already over 22 MB at page 35. Is there any way to reduce the size of these files as they will then be retrieved and emailed. The application is asp.net webforms using ms reportviewer.

this is the code I used to save the report. I created a LocalReport in the code behind instead of using the reportviewer control beause we don't need to display the report.

            private void SavePdf()
            {
                  var path = GetReportPath();

                  var bytes = _localReport.Render(
                        "PDF", null, out string mimeType, out var encoding, out var filenameExtension,
                        out var streamIds, out var warnings);

                  using (var fs = new FileStream(path, FileMode.Create))
                  {
                        fs.Write(bytes, 0, bytes.Length);
                  }
            }

this is the code to create the report before saving it as a pdf.

            private void RenderReportForSaving()
            {
                  var reportDataSource = new ReportDataSource("DataSet1", base.GetDiscipleshipReportView());

                  try
                  {
                        var path = Server.MapPath($"~/Administration/Reporting/Reports/{_reportType}.rdlc");
                        var report = new LocalReport();

                        _localReport.EnableExternalImages = true;
                        _localReport.ReportPath = path;
                        _localReport.DataSources.Clear();
                        _localReport.DataSources.Add(reportDataSource);

                        AddSubQueriesToLocalReport();

                        _localReport.Refresh();
                  }
                  catch (Exception ex)
                  {
                        …
0
Hi

In ASP.net I want to draw a horizontal line across 80% of the screen width
How do I modify     <hr/>  to do this, or should I use something else?
0
I have this date string:
2018/05/23 22:15:14

I want to subtract 5 hours and return the date time in AM/PM format. But when I do, I get the message:
String was not recognized as a valid DateTime.

I've tried:

                  Dim newdate As DateTime = Now()
                    Dim getDate2 As String = "2018/05/23 22:15:14"

 newdate = DateTime.ParseExact(getDate2, "MM/dd/yyyy HH:mm:ss", Nothing)
and this:
newdate = DateTime.Parse(getDate2)

I was going to do this afterwards to deduct the 5 hours, but I never get that far:
newdate = newdate.Date().AddHours(-5)

I saw a webpage with an example and it has this:
' From w3.org
        time = DateTime.Parse("2009/02/26 18:37:58")

So why is this not a valid datetime?
2018/05/23 22:15:14

thanks!
0
Hi
In my ASP.net web app I get the following message after publishing.
I get that I have to change my web.config file but do I have to also add
a web page called mycustompage.htm? Do I just add this to my project folder?
Can I fir example change the name to MyErrors.html?
Thanks

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
  

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.



<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
 

Open in new window

0
I am trying to return a series of rows into one array but this is for dates, the following works for text but not dates:


Declare @Datelist AS Nvarchar(MAX)
SELECT  @Datelist = COALESCE(@Datelist + ',', '') + [StartDate]
FROM   tbl_QuizDetails where StartDate IS NOT NULL

SELECT @Datelist

Open in new window


Am I able to convert the date to string or keep these as dates in the single string?

Any help is appreciated.

Regards
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