.NET Programming





The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

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

Sign up to Post

Suppose I have 2 large files.  If I want to compare them using a MATCH function in Excel it could take hours.
If I load them into a SQL Database and do an inner join it can take minutes or seconds.

I want to compare some large files in Visual Studio 2010 (C#) and was wondering if I could compare them in minutes rather than hours without actually uploading them to a SQL Database.

From what I know, if you are documenting a data structure (e.g. JSON) with embedded objects, you might have something like this for the data schema tables:

DISCLAIMER: In the real world, I doubt you'd have a full (e.g.) doctor object embedded in the prescription object. More likely, you'd have a record number for patient, doctor, drug, but the below is useful for this example. :)

Rx Number
Patient Object
Doctor Object
Drug Object

You'd then have tables for the aforementioned objects, which themselves could contain objects:
IdNumbers Object

And in turn...
Now, to the question. I'm documenting an API where some of the embedded objects contain only one field/object. To use the above example, something like:

PRESCRIPTION OBJECT (as before: contains many fields/objects)

DOCTOR OBJECT (Contains one object)
IdNumbers Object

ID NUMBERS OBJECT (Contains one field)

Per the above, would I be overdoing it to have separate data tables for these objects containing only one field/object? If so, I'd need to find a clean way to embed everything in the parent table.

On our web we are using Telerik RadGrids from WAY back... version is several years old.

In production and on the web itself the Grids appear correctly and function correctly.  No issues.

When on the server (Amazon EC2 instance - MIcrosoft Windows Server 2012 R2)

And running web in debug mode

The grids all appear with no columns organized... its like the data is just dumped in the grid.

Please see the image below.

this is the code :

using (var wb = new WebClient())
                var data = new NameValueCollection();
                data["username"] = "adam";
                data["password"] = "1234";

                var response = wb.UploadValues("http://XXXXXX/api/login", "POST", data);
                return response.ToString();

Open in new window

the user and password I need to send in the body of the request

the error msg :
The remote server returned an error: (400) Bad Request.
what is wrong?
thanks ...
Hi Guys,
I'm using the DateTime class and I'm trying to return the last two week with this format:

Nov  1 - 15.

so, I'm doing something like:
List<DateTime> LastMonthFirst2Week = (from i in Enumerable.Range(0, 2) select DateTime.Today.AddDays(-(i * 12))).ToList();

 foreach (var t in LastMonthFirst2Week)
                var tf = new Timeframe();
                tf.LastMonthFirst2Week = t.ToString("MMM d");

Open in new window

by doing what I post above it gives me Nov 1 - so how do I get the end of it.? like the 15

Hello. I would like to make a "same as mailing address" section on a form.  If the checkbox labeled "Address same as client" is checked then the panel with the textboxes to record address information will disappear and the person can submit the form without filling out the information.  However, if that box is not checked the the panel with the textboxes to record address information should be visible and the user should be forced to fill out that information before the form can be submitted.  I know how to do validation but not in this situation.  Here is the code I have so far.  

This is the code for the checkbox:
Mailing Address:<asp:CheckBox ID="chkAddrSameAsClient" runat="server" Text="Address same as client" AutoPostBack="true" OnCheckedChanged="chkAddrSameAsClient_CheckedChanged"/

Open in new window

Here is the panel code for the textboxes that will record address information:
<asp:Panel ID="pnlGuarantorAddress" runat="server">
           <table style="width: 100%;">
                       <asp:TextBox ID="txtGuarantorAddress" runat="server" Width="400px">Street Address</asp:TextBox>
                       <asp:RequiredFieldValidator ID="txtGuarantorAddressValidator1" runat="server" ControlToValidate="txtGuarantorAddress" Display="Dynamic" ErrorMessage="Please enter guarantor's address"></asp:RequiredFieldValidator>

Open in new window

What is the vb.net version of the following code?

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(document).ready(function () { custom1(); });", true);

Open in new window

When a user function or operation executes in our asp.net application, a confirmation email is sent out, using the SMTP credentials found in the web.config file.
Q- When an external user has logged onto the application, and is performing the process, could their internal corporate firewall block the email being sent out by the app? I am not sure if the email is generated from the host server, or via the user's local session.
Thanks for your input.
hi guys,
I'm trying to return dates from my server to a page and I'm using DateTime class.

The order I'm trying to return is:
For example "last month"  
1 jan - 7 jan - 8 jan - 14 jan - 15 jan - 21 jan - 22 jan - 28 jan

Any idea how to do it with datetime class.

My code below is on a .aspx page.

The test1 button works fine as long as I place it outside the form tag
Button pops just fine

But it opens and closes when the button is placed inside the form tag... not really a problem because what I want to do is use a .net button inside the form tag

Then... on .Net button click
I run some code...
And execute the custom1(); from server side.

Here is all the code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>
    <title>HTML, CSS and JavaScript demo</title>
    <script src="https://cdn.jsdelivr.net/npm/uglipop@1.0.0/uglipop.js"></script>

        .put {
            border-radius: 10px;
            background-color: white;
            width: 300px;
            height: 300px;
            padding: 10px;
            -webkit-box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
            -moz-box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
            box-shadow: 0px 0px 39px 12px rgba(0,0,0,0.75);
    <!-- Start your code here -->
    <form id="form1" runat="server">

        <p class="lw">Hello Weaver!</p>
        <asp:Button ID="btnClick" runat="server" Text=".Net Buttone" OnClick="btnClick_Click" />

        <button class="button-blue" id="test1" runat="server" onclick="custom1();">Try it</button><br />
        <br />
        var custom1 = function

Open in new window

The following example makes use of JSONObject and JSONArray where JSONObject is a java.util.Map and JSONArray is a java.util.List, so you can access them with standard operations of Map or List.

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.ParseException;
import org.json.simple.parser.JSONParser;

class JsonDecodeDemo {

   public static void main(String[] args){
      JSONParser parser = new JSONParser();
      String s = "[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
         Object obj = parser.parse(s);
         JSONArray array = (JSONArray)obj;
         System.out.println("The 2nd element of array");

         JSONObject obj2 = (JSONObject)array.get(1);
         System.out.println("Field \"1\"");

         s = "{}";
         obj = parser.parse(s);

         s = "[5,]";
         obj = parser.parse(s);

         s = "[5,,2]";
         obj = parser.parse(s);
      }catch(ParseException pe){
         System.out.println("position: " + pe.getPosition());
On compiling and executing the above program, the following result will be generated −

The 2nd element of array

Field "1"

Open in new window

import org.json.simple.JSONObject;

class JsonEncodeDemo {

   public static void main(String[] args){
      JSONObject obj = new JSONObject();

      obj.put("name", "foo");
      obj.put("num", new Integer(100));
      obj.put("balance", new Double(1000.21));
      obj.put("is_vip", new Boolean(true));

On compiling and executing the above program the following result will be generated −

{"balance": 1000.21, "num":100, "is_vip":true, "name":"foo"}

Open in new window

what above example doing
is it encoding jsonobject to java object?
i see output also seems like json to me?
Following is another example that shows a JSON object streaming using Java JSONObject −

import org.json.simple.JSONObject;

class JsonEncodeDemo {

   public static void main(String[] args){
      JSONObject obj = new JSONObject();

      obj.put("num",new Integer(100));
      obj.put("balance",new Double(1000.21));
      obj.put("is_vip",new Boolean(true));

      StringWriter out = new StringWriter();
      String jsonText = out.toString();
On compiling and executing the above program, the following result is generated −

{"balance": 1000.21, "num":100, "is_vip":true, "name":"foo"}

Open in new window

how above one is differen from first one?
Is it possible in JavaScript...

That once an <input> length = 12 characters (4111111111111111)
to show * instead of the actual first 8 characters  (************1111)

But have the real this.value still be available for calculations and saving to database
I have a working GridView bound to SQL query, and I'm adding onto it, a new TemplateField  via:
                    <asp:BoundField DataField="spid" HeaderText="spid" SortExpression="spid" />
                    <asp:BoundField DataField="Login" HeaderText="Login" ReadOnly="True" SortExpression="Login" />
                    <asp:BoundField DataField="DB" HeaderText="DB" ReadOnly="True" SortExpression="DB" />
                    <asp:BoundField DataField="SERVER" HeaderText="SERVER" SortExpression="SERVER"/>
                    <asp:BoundField DataField="LOGIN TIME" HeaderText="LOGIN TIME" ReadOnly="True" SortExpression="LOGIN TIME"/>
                    <asp:BoundField DataField="USER COUNT" HeaderText="USER COUNT" ReadOnly="True" SortExpression="USER COUNT" visible="FALSE"/>
                    <%--<asp:BoundField DataField="siteName" HeaderText="SITE" SortExpression="siteName"/>--%>
                    <asp:TemplateField HeaderText="SiteName" SortExpression="Sitename"> 
                            <asp:Label ID="lblSiteName" runat="server"></asp:Label> 


Open in new window

I'm trying to use:
    Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound

Open in new window

to then, populate the new column cells with text, but I notice that when stepping through the code, if I highlight GridView1
in as seen below:
as you can see, the GridView has NO rows.
So, somehow, I'm losing the bindings before entering the even handler...?
See in installation notes for proplus that version 3.5 .Net Framework required for regular office applications and 4.5 clr needed for Skype for Business.

These don't come with Windows 10 natively . Using a BYOD model just wondering what the importance of .Net is and what errors it will generate if the correct version isn't used?
I am looking for an eConnect method that will add an Item Warehouse record,  I am currently doing this using GP Web Services call CreateItemWarehouse(), but we find this to be much slower than using eConnect.  Any help would be appreciated.

Thanks, Bob
what are differences between json and xml. what are advantages, disadvantages of each

I read like below
JSON uses typed objects. All XML values are typeless strings and must be parsed at runtime
what it mean by typed object and typeless strings and runtime parsing

please advise
I have a web page with an input where users enter 8 characters.

I would like to be able .... after the FIRST character entered in an input tag

To "set" an image

The first character will always be numeric in a alphanumeric string

In txtUserInput a user enters a "1"

The image would be set... and display with a src="../img/sub/1Href.jpg"

The user types In a "2"

The image would be set... and display with a src="../img/sub/2Href.jpg"

<input id="txtUserInput" runat="server" class="field" placeholder="Enter Code" style="border: solid 1px #c1c1c1; width: 70%; font-size: 50px; float: left;" />

<img src="#" alt="" />
I am trying to set me context menu right click location to open whenever the user clicks on my control (Me.GridSpread). It always seem to open on right click of the context control itself on the upper menu button area.

Private Sub frmSearch_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then
            SearchContextMenu.Show(Me.GridSpread, New System.Drawing.Point(0, 200))
        End If
    End Sub

Open in new window


i was trying to understand below ajax json example using xmlhttpobject to get file data from server

i am not sure what is happening here.

<!DOCTYPE html>

<h2>Use the XMLHttpRequest to get the content of a file.</h2>
<p>The content is written in JSON format, and can easily be converted into a JavaScript object.</p>

<p id="demo"></p>


var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var myObj = JSON.parse(this.responseText);
        document.getElementById("demo").innerHTML = myObj.name;
xmlhttp.open("GET", "json_demo.txt", true);


<p>Take a look at <a href="json_demo.txt" target="_blank">json_demo.txt</a></p>


Open in new window

what it means by below?

where is the server path?

what is meaning of below lines

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var myObj = JSON.parse(this.responseText);
        document.getElementById("demo").innerHTML = myObj.name;
xmlhttp.open("GET", "json_demo.txt", true);
when is onreadystatechange related function called and what is 4 and 200 here?
why we need to use JSON.parse

please advise
Hello Experts,

I have deployed the following C# script in Azure, however I'm constantly getting the following error when I enter the firstname and lastname parameters as shown in the image

using System.Net;
        public static async Task<HttpResponseMessage> 
        Run(HttpRequestMessage req, TraceWriter log)
            string firstname=null,lastname = null;
            dynamic data = await req.Content.ReadAsAsync<object>();
            firstname = firstname ?? data?.firstname;
            lastname = data?.lastname;
            return (lastname + firstname) == null ? 
             "Please pass a name on the query string or in the 
             request body") : 
            req.CreateResponse(HttpStatusCode.OK, "Hello " + 
             firstname + " " + lastname);

Open in new window

The following is the error message@

2017-11-27T16:37:37.340 Function started (Id=a7a78773-bf61-44b3-999a-3792ac4dd28f)2017-11-27T16:37:37.351 Function compilation error2017-11-27T16:37:37.351 run.csx(11,14): error CS1010: Newline in constant2017-11-27T16:37:37.351 run.csx(11,64): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,22): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,26): error CS1003: Syntax error, ',' expected2017-11-27T16:37:37.351 run.csx(12,26): error CS1010: Newline in constant2017-11-27T16:37:37.351 run.csx(12,31): error 

Open in new window

i was reading below link

what it mean  by

rest web services stateless and allow caching
how stateless allows to cache webservice responses?
how caching is related to statelessness of http?
please advise
Using C# while writing a Windows Form application.

I have a "main" UserControl which I intend to use for showing a collection of other UserControls.

Right now I am keeping it simple and just hard-coding the adding of the usercontrols to the "main" usercontrol.

I added 300 of the controls and they seemed to add okay.

But when I scroll the window for the "main" control there is a bunch of ... lag?  ... as i scroll.  The mouse pointer begins to move in slow motion.  My guess is that it is related to the "main" control re-drawing itself.  Once that process finishes, the mouse speed goes back to normal.

Tips?  Tricks?

I cannot believe that I am taxing the operating system THAT MUCH with my simple controls.  We're talking about bunch of textboxes, for crying out loud.

DataGridViews can have a lot more data and they scroll with no lag.  So what am i doing that is so different?

Frustrated that I am having to put up with this!  C# and Window Forms development has been around for a while.

code for adding my user controls to the "MAIN" control:

using System.Data;
using System.Windows.Forms;

namespace DocumentController
    public partial class InMemoryGrid : UserControl
        public InMemoryGrid()

            InMemoryRow imr;

            InMemoryCell imc;

            UniversalDataClass udc;

            int top = 0;

            for(int i = 0; i < 300; i++)

Open in new window

I bought this template Angular 4 template

I've been  Googling for the past two weeks and read a lot of articles on how to set an Angular 4 project. This is one of the articles I followed
Example to setup Angular 4 with MVC

I installed Node and Angular CLI. Created an MVC project. Copied the files from the template to the MVC project. I did ng build and ng serve and the index.html page comes up.

At work, we use AngularJS with ASP.Net MVC. We have the AngularJS code along with MVC controllers. Projects have ASP.Net's Identity/Membership, the login page, etc.

 So far so good.

I followed the article to "The Development Workflow and Live Reloading"  section.


1.  In Angular 4, how can I remove index.html and have Razor (index.cshtml) as the first page? I want to have a login page with Asp.Net's Identity (I'm customizing the Angular 4 template I got...don't want to use it out of the box...I want to integrate the design into ASP.Net project I'm creating)

If you look at the article I posted, it has this section "The ASP.NET MVC Index Razor View Page". I don't quite understand it but is that something I need to do to integrate ASP.Net with Angular 4?

2. Should I even be using an Angular 4 project with ASP.Net? I'm thinking I have to because I want to use webconfig settings, ASP.Net's Identity/Membership for login, MVC controllers....just like how we did AngularJS

3. This is another article Another example
Hi Experts,
I have an MVC.Net application with C#.Net code behind.
I want to use a Viewbag value to determine if some columns in my Kendo UI grid should be hidden or not.

below is a snippet of the code I was trying to use, but it does not work.
How can I make this work?

columns: [
             field: "IPA",
             title: "IPA",
             field: "TEST",
             title: "TEST",

Open in new window

Thanks in advance,

.NET Programming





The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.