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

Hello Experts,

I have an issue with C# List, when I add values it showing the duplicates data.

using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		Student std = new Student();
		List<Student> studentList = new List<Student>();
		
		std.ID = 1;
		std.Name = "John";
		studentList.Add(std);
		
		
		std.ID = 2;
		std.Name = "Doe";
		studentList.Add(std);	
		
		
		Console.WriteLine(studentList.Count);//count
		
		Console.WriteLine(studentList[0].ID); //ID
		Console.WriteLine(studentList[0].Name); //Name
	}
}

public class Student
{ 
	public int ID { get; set; }
	public string Name { get; set; }
}

Open in new window


Output:
2
2
Doe

The count was correct, but I was expecting below output and the list shows duplicates:

2 -- >Count
1 --> ID
John -- > Name

Please help, what I was doing incorrect.

Thanks,
ASPDEV
0
Rowby Goren Makes an Impact on Screen and Online
LVL 13
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

My HiddentFields are getting document.getElementById are not working as expected inside javascript in asp.net. Everytime I tried set a value for hidden field I get the following error

Uncaught TypeError : Cannot ready property 'value" of null


In the below code there is a javascript function loadfile().
This is the line where i am getting the error : document.getElementById("hAction").value = "";
if I move past that error the next step where i have to read/update value for a variable I am getting the above mentioned error. So looks like somewhere the variables are not getting set correctly

Here is my aspx code :

<%@ Page Language="C#"  MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeBehind="A.aspx.cs" Inherits="A" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ MasterType VirtualPath="~/MasterPage2.master" %>

<asp:Content ID="Content2" ContentPlaceHolderID="CP1" runat="Server">


<meta http-equiv="Pragma" content="nocache">
<meta http-equiv="Expires" content="-1">
<title>Account Exception Upload</title>
<%--<script type="text/javascript" src="ccr_scripts.js"></script>--%>
<script type="text/javascript" src="/apps/jfunctions.js"></script>
<script type="text/javascript" src="/apps/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="/apps/commonStyles.css" />

<script type="text/javascript">

var timerID = -1;

function cancelProcessing()
{
	if (confirm("Are you 

Open in new window

0
hiii im using crystal report in my web application in which i have a main report and a subreport my problem is that in my subreport i have passed a store procedure which except parameter @relationid so in code behind i have used this code to set that parameter value which is  

rpt.SetParameterValue("@relationid", documentId, rpt.Subreports[0].Name.ToString());

i have linked subreport with main report parameter but im getting this error  which is attached below  any solution thanks in advance
Capture.PNG
0
Hello Experts,

I'm new to MVC and JQuery web development. I'm trying to bind the data to my datatable using JSon object. Below is the sample code:

View
<div id="mdlMsg" class="modal fade" tabindex="-1" role="dialog">
            <div class="table-responsive m-t-40">
                <table id="dtData" class="display nowrap table  dataTable" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>Col1</th>
                            <th>Col2</th>
                        </tr>
                    </thead>
                    <tbody id="tblbody"></tbody>
                </table>
            </div>
        </div>

Open in new window


Controller
public async Task<ActionResult> Test()
{
 string resp = "";
  var msg = new Dictionary<int, string>();
msg .Add(1, 'Row 1');               
msg .Add(2, 'Row 2');       
      resp= Newtonsoft.Json.JsonConvert.SerializeObject(msg, Newtonsoft.Json.Formatting.Indented);
return resp;
}

Open in new window


Javascript
$.ajax({
        type: 'post',
        url: url,
        processData: false,
        contentType: false,
        data: files,
        success: function (resp) {
 $('#mdlMsg').modal({ show: true })
                var jsonTst = $.parseJSON(resp);
                $('#dtData').dataTable({
                    "bAutoWidth": false,
                    "aaData": jsonTst.data,   //this is your JSON object, which is what is showing in your post above with console.log(data)
                    "aoColumns": [{
                        "jsonTst": "Col1"
                    }, {
                            "jsonTst": "Col2"
                    }]
                });
});

Open in new window


The modal popup shows with no data and also I want to fix my Modal popup to be middle of the page.

Thanks,
ASPDEV
0
I save a class with various properties into a the current user session like this :
    Public ReadOnly Property UserSession As cUserSession
        Get
            If HttpContext.Current.Session("UserSession") Is Nothing Then
                HttpContext.Current.Session.Add("UserSession", New cUserSession)
            End If
            Return DirectCast(HttpContext.Current.Session("UserSession"), cUserSession)
        End Get
    End Property

Open in new window

I would like to save details in the class to a database before the session is lost.  If I rely upon Session_End in global.aspx, the object is already lost when I go to save it.  I tried to implement idisposable in the cUserSession but this didn't fire.  Whilst I can see how I can manually save the contents of the session by user action or property change, I would like to only do that when the session is about to be lost.

Is this achievable?

Thank you,
0
We have a vendor installed site on a local server in IIS.  They said the site only works in Chrome.  The site allows tickets to be printed by clicking a button called "PDF" which then generates and downloads a PDF.  For some tickets it works and others get "Failed - Network error".  It's not random, the same ticket either works every time or doesn't.  We can download those same tickets that don't work in Chrome, in Edge and Firefox without issue.  But Edge and Firefox have other view issues so we can't just switch to them.  Everything else within this site works fine in Chrome.  We've already tested disabling AV, UTM services, etc.  Those had no affect.  I'm thinking this issue lies in IIS or the code of the site.
0
Hi

      I am trying to build an html button for an email where the button is wrapped in a table cell using the following code. It isn't working properly as shown in the attached image

      Dim oLinkAccept As String = "http://SteelYard.azurewebsites.net/offers_to_me?oOfferID=" & oNewOfferID & "&oOfferAcceptDecline=Accept"

            oHBody = oHBody & TableCellWrapper("<a href=" & oLinkAccept & " style='padding: 8px 12px; border: 1px solid #006400;border-radius: 2px;font-family: Helvetica, Arial, sans - serif;font-size:   14px; color: #006400;text-decoration: none;font-weight:bold;display: inline-block;' >ACCEPT</a>")

    Function TableCellWrapper(ByVal X As String) As String

        Dim S As String

        S = "<table width = '100%' cellspacing='0' cellpadding='0'>"
        S &= S & "<tr>"
        S &= S & "<td>"
        S &= S & "<table cellspacing = '0' cellpadding='0'>"
        S &= S & "<tr>"
        S &= S & "<td style = 'border-radius: 2px;' bgcolor='#ED2939'>"
        '<a  Class=”link” href="https://www.copernica.com" target="_blank">
        'Click            
        '</a>
        S &= S & X
        S &= S & "</td>"
        S &= S & "</tr>"
        S &= S & "</table>"
        S &= S & "</td>"
        S &= S & "</tr>"
        S &= S & "</table>"



        TableCellWrapper = S

    End Function

Image1.jpg
0
If there is not action verb quoted in front of the method, does it mean it accept HttpGet ?

ThxAudioBookManualController
0
I have gridview in my asp.net form. there is an account number column in there which gets populated from a database. I want the entire account number to be masked with "*" and on mouse hover to the account number I want to see the actual account number. Can I please have an example for something like this.
0
What does the line below perform ?

audioServiceMock.Setup(x => x.Update(It.IsAny<Guid>(), It.Is<AudioBook>(ab => ab == audioBook))).Returns(audioBook)
TestCode02.png
0
Amazon Web Services
LVL 13
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Any idea what's the mock code in attached file mean ? What does x in #2 perform ?

Thx
TestCode01.png
0
Can anyone explain what the attached code mean ?
TestCode.png
0
Hi

I have inhertited a Reg Ex patter to validate mobile phone numbers.

/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/g;

I need to change it to validate an 8 digit number, starting with 2.

Can anyone help please.
0
I have added some extra fields to the aspnet_user tables, one of the fields is a Boolean - ResetPassword that is set to true when user is first created by the Admin.

When the user logs in if the field is a Boolean is sends user to change password - once the user successfully changes their password I want to update the field to false - how do i update a field in the Identity User table easily ?

Thanks
0
Hello,

I am fairly new to the TFS environment and have tried to load an existing project saved to TFS into my local machine for development.

1. I identified the library and performed a get-latest
2. Entereed NUGET and did a RESTORE-ALL

Afterwards I found that no dll references whatever were restored.
How can I accomplish this on a regular basis?
From my readings it seems that there is no straightforward solution other tha creating a local folder and moving the DLLs into and re-referencing to that folder.

The problem with all of that is that this project was not built from an empty project andf has a lot of boilerplate DLLs (ASP.NET project) that are not used such as ANTLER. So the DLL list is quite long.

Thanks in advance

Charlie
0
I have a common web config connection strings in asp.net / IIS / MS SQL Server Express DB.
When it is on localhost, everything is working. Both file web config & connectionstrings.config file are in the same directory level.

When it is on www.abc.com, the database does not read and have no error message.
Any idea how to fix it?

Web config
<connectionStrings configSource="connectionStrings.config" />

Open in new window


connectionStrings.config file name
<add 
       name="pwrsssdfsadfasdf_connectionstring"  
       connectionString="Data Source=WIN-GB8M3MMasdfasdf6T2M\SQLEXPRESS;Initial Catalog=dbdata;Integrated Security=True;User ID=sa;Password=asdfdsa000!"
       providerName="System.Data.SqlClient"
       />

Open in new window

0
I have the following db string  inside of my web app. The localhost work but the live website does not work. do you know how to fix it?
Both DB/IIS is in the same AWS instance.

 <add name="ConnectionString" connectionString="Data Source=WIN-GB8M3MM6asdfasdT2M\SQLEXPRESS;Initial Catalog=Pwr;Integrated Security=True;"
      providerName="System.Data.SqlClient" />
0
Hi

In ASP.net I am getting the error 0 of 21 Errors with no errors showing I the error list
What do I do to find the errors?
Image1.jpg
0
I have two text boxes where user can select dates, then click the submit button to populate a webgrid, this works, but when I click on the sort or the filter the dates in the texboxes are not passed back and reset to current date - how can I keep the dates so I can utilize the sort, filters.

here is the code i am using

VIEW
@model IGrid<rptEODTelco>


@{
    ViewData["Title"] = "EOD Telco Summary";

}

<head>
    <link href="~/css/mvc-grid/mvc-grid.css" rel="stylesheet">
</head>

<div class="col-md-12">
    <div class="form-group">
        <form action="/Reports/EODTelcoSummary" method="post">
            <label for="StartDate">Start Date:</label>
            <input type="date" name="StartDate" value="@ViewBag.StartDate" />
            <label for="EndDate">End Date:</label>
            <input type="date" name="EndDate" value="@ViewBag.EndDate" />
            <button type="submit">Submit</button>
        </form>
    </div>
</div>

<div class="col-md-12">
    <div class="panel panel-primary list-panel">
        <div class="panel-heading list-panel-heading">
            <table align="center" width="100%">
                <tr>
                    <td align="center" colspan="2"><span style="font-size:28px;">EOD Telco Summary</span></td>
                </tr>
            </table>

        </div>
    </div>
    <div class="class=" panel-body">
        @(new HtmlGrid<rptEODTelco>(Html, Model))
    </div>
</div>

<script src="~/js/mvc-grid/mvc-grid.js"></script>
<script>

Open in new window

0
Become a CompTIA Certified Healthcare IT Tech
LVL 13
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

I am sending a file with  HttpContext.Current.Response

I need to loop through, create a file, send it to the browser for download. Then create another file and send it to the browser for download.

On the second one I get an error:
Server Cannot Append Header After HTTP headers have been sent Exception

So I added this:
HttpContext.Current.Response.ClearHeaders()

and now get this error:
Server cannot clear headers after HTTP headers have been sent.

Any solutions for sending multiple files without intervention from the user? (someone said to put a button for each file, that is not an option, as we are sending a file for every 100 pages as an example and don't know how many files we might have and we could be spamming a ton of buttons to the screen and making them click them all and remember which one they clicked).

Someone else suggested zipping up the files, but due to most of our clients not being allowed to install on their machines and people all fretting over viruses in zip files, the boss does not see that as a solution.

What solutions do you recommend that you have used?

Thanks!
0
I use a datatable to do some sorting for a GridView

dtSort.DefaultView.Sort = e.SortExpression + (string)((e.SortDirection == SortDirection.Ascending) ? " ASC" : " DESC");

Then I save the dtSort in ViewState["DataTable2"].
And then use it with the GridView. And it get sorted. Sorting works great in the GridView.

But when I set this same sorted datatable (ViewState["DataTable2"]) as DetailsViews datasource it looks like the sortorder not comes here.
Then the PageID is not the same as the rowindex in the GridView. I got the rowindex from the DataTable and not from the GridView so it should work in both GridView and DetailsView objects?

What do I miss? Looks like it works different in GridView and DetailsView?
0
hi

i have a drop down list filled from server side as below:
(where SelectStatusCbo is the drop down and lStatusDS is the dataset)
 With SelectStatusCbo
                            .DataSource = lStatusDS.Tables(0)
                            .DataTextField = "Status_DescE" '"P_cle_stat"
                            .DataValueField = "internalCode" '"p_stat_int"
                            .DataBind()
                        End With
the dataset contains teh below column :
Process1, Status_DescE and internalCode
nowin javascript i need to do  the below:
 $("#" + SelectStatusCbo.id).on("change", function () {
//need to read the dataset and appropriate column of teh datase how to dow it?
}
well i need to read the dataset of the drop down in javascript goto the selected index and read each column value how to do it?
0
I encounters an error when running the ASP Core app. Actually, I have no idea which Microsoft.EntityFrameworkCore should I refer in my project ? I suppose my app is running 3.0.0-preview8-28405-07. Am I correct ?

Thx
0
Hi I am getting the following error is my ASP.net web app when I click a GridView button. I am using .net framework 4.6.1. What would cause this

Server Error in '/' Application.
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +9935848
   System.Web.HttpRequest.FillInFormCollection() +415
   System.Web.HttpRequest.EnsureForm() +69
   System.Web.HttpRequest.get_Form() +13
   System.Web.HttpRequest.get_HasForm() +9932779
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +95
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +130

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3429.0
0
Hi. In ASP.net what VB.net code would I use to see if the site has been published. I have to run slightly different code to what I run in debug mode.
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