.NET Programming

134K

Solutions

39K

Contributors

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

convert .aspx to .doc maintain header footer positions
0
Hi there.

I started working on a new VB.NET project. It's my first real attempt to make a .NET project. I used classic asp in the past, and all those files is tricking me. This is the case:
At my hosting company I have some old projects stored. In the www-folder (the root of my webserver) I have subfolders with projects, and this new .NET has got a folder too.
Now when I try to publish my very first page, I get an error message with compiling.
When I publish my project, the web.config ends up in the project-folder. Not in the www.root. So I moved it manually to the root on the server, but I have the feeling that it's not the right thing to do.
Can anyone please guide me how to do the publishing correct? Let me know if you need more info.

Best regards

Ulrich
0
Hi,

I have a database column which is the arrival time of the patient to the clinic as TIME(7) data type.

I am struggling in viewing it to the data grid view column.

public string ArrivalTimeFormatted { get { return ArrivalTime?.ToString("hh\\:mm\\:ss"); }}

Open in new window


How can I add PM, AM to the ArrivalTimeFormatted property?

Thanks,
0
Hi All,

I'm trying to expand programmatically an accordion menu based on saved values in local-storage.
The problem is that it saves the values, i get back the values, but it's not expanding the active ones.
I use the following accordion library:
(function(jQuery){
     jQuery.fn.extend({  
         accordion: function() {       
            return this.each(function() {
            	
            	var $ul = $(this);
            	
				if($ul.data('accordiated'))
					return false;
													
				$.each($ul.find('ul, li>div'), function(){
					$(this).data('accordiated', true);
					$(this).hide();
				});
				
				$.each($ul.find('a'), function(){
					$(this).click(function(e){
						activate(this);
						return void(0);
					});
				});
				
				var active = (location.hash)?$(this).find('a[href=' + location.hash + ']')[0]:'';

				if(active){
					activate(active, 'toggle');
					$(active).parents().show();
				}
				
				function activate(el,effect){
					$(el).parent('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
					$(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'fast':null);
				}
				
            });
        } 
    }); 
})(jQuery);

Open in new window


My HTML (i generate the menu from C#) + JS: Init that gets the menus/submenus that i clicked earlier (but not expanding them :o(   ):
<!--MENU-->
<div id="pageWrap" class="pageWrap">
	<div class="pageContent">
		<ul class="accordion">
			<div

Open in new window

1
I have a .resx file in my resource folder. I'm trying to use ResXResourceWriter but it requires a path to the file. When I'm debugging I can just put a path to the file in my projects resource folder, but when it comes time to release the application it won't work since the application should only be one .exe file without any folders or additional files. I'm trying to do
ResXResourceWriter resx = new ResXResourceWriter(Properties.Resources.[File Name])

Open in new window

but it only seems to give me an error "Illegal characters in path."
0
I am a C# programmer. I'd like to start learning ASP.NET, but before that I'd have a couple of questions:

1. Should I learn ASP,NET Core or ASP.NET MVC? (What I need is to dynamically reformat pages on an existing web, at request, and also to provide user feedback forms that should access a database.)

2. I have on location an old Windows Server 2003 and another 2008, which I thought of using for testing samples. Can the framework required by ASP.NET Core be installed on such older servers? Would older IIS handle the job?

3. This book "ASP.NET Core in Action" is recent but some readers complain it's too verbose. Would you recommend another book/tutorial?
0
Hello,

I have a solution with 2 projects. I want to build/compile one project from another. To be more exact I want a user that will be using ProjectNR1 to enter the information then the information should be passed to ProjectNR2 and then the project(ProjectNR2) builds/compiles. So the question I have is: How to compile a VisualStudio 2019 project programmatically using C# (It's a windows forms application). I have been trying to figure out this all day with no luck.
0
I am looking for the best DB giving the following considerations.

1)  I will be deploying a .net /angular application into Azure via Docker / Kubernetes.

2)  I would want on prem and cloud capabilities..natively

3)  Finally we will be moving to AWS in the next year..so migration is important as well.


I will want to use relational database.  High availability, on prem and off prem  capabilities, as well as other great scaling capabilities.

Also having a hard time with the cost model here...so any knowledge there would be helpful.

I will be doing this in a CI/CD ...I am guessing I would have docker in my local enviornment (free)  then move to a dev / stage/ prod enviornment.
0
Hi
in the code bellow I'm trying to remove 1080p | HD either in or out of ()
I butl the using regexq101
this appears to work except for last witespace
however I'm not getting the expacted reults


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;

namespace Remove1080p
{
    class Program
    {
        static void Main(string[] args)
        {
            string Root = "";
            Console.WriteLine(@"Drag folder");
            string Ans = Console.ReadLine();
            if (Ans == "")
            {
                Console.WriteLine("Need a folder");

                Console.WriteLine(@"Drag folder");
                Ans = Console.ReadLine();
            }
            if (Ans != "")
            {
                Root = Ans;
                if (Root.EndsWith(@""""))
                {
                    Root = Root.Trim(new char[] { '"' });
                    Console.WriteLine("trimed " + Root);
                }
            }
            Regex regex = new Regex(@"(\s+(\(1080p\s+HD\))|(\(1080p\)|(\(regex\))|1080p|720p|HD)\s+)");

            string[] Files = Directory.GetFiles(Root);
            foreach (string file in Files)
            {
                Console.WriteLine("File " + file);
                FileInfo fi = new FileInfo(file);
                string Ext = fi.Extension;

              

Open in new window

0
Hi,

Hi, I am using this online solution for Grideview Drag and Drop asp.net web forms (https://www.aspsnippets.com/Articles/Reorder-GridView-Rows-Drag-and-Drop-ordering-of-GridView-Rows-using-jQuery-in-ASPNet.aspx).  Everything works fine but now I need help updating the database table with additional fields.  For example:  I need to update the table of who dragged and dropped the row.  I added the "UpdateBy" field to my update statement , it works, but it updates every row with the value not the one row that was dropped.  What am i missing? Please need help asap.

  

  Private Sub BindGrid()
        Dim query As String = "SELECT [id], [DisplayOrder], [STUDY], [PATIENT],[WAIT_TIME],[USER_ID],[UpdateBy] FROM [Radio_queue4] " +
"order by DisplayOrder asc"
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand(query)
                Using sda As New SqlDataAdapter()
                    cmd.CommandType = CommandType.Text
                    cmd.Connection = con
                    sda.SelectCommand = cmd
                    Using dt As New DataTable()
                        sda.Fill(dt)
                        grid.DataSource = dt
                        grid.DataBind()
                    End Using
                End Using
            End Using
        End Using
    End Sub

 Protected Sub UpdatePreference(sender As Object, e As 

Open in new window

0
I am learning angularjs , and have mostly worked in .net space.

what are few ways/tools/tips/tricks to debug angular code?
0
Hi All,

I have a .net core web api app that services iOS and Android mobile devices. Then i have an asp.net core MVC web app but im wondering about breaking this out into its own angular/vue/react app that consumes the .net core web api. The current MVC web app is where users can change password, change email preferences, etc.

What are the pros and cons of this? I feel like it will allow us to consume more functionality of the .net core web api into our webapp which is really basic right now.

Matt
0
I am trying to get a range of cells from a sheet to populate my graph on a different sheet inside my excel workbook. When it hits the line "  chartRange = oWB.oSheet("Sheet1").Range("A1", "A136")" It throws an error "System.MissingMemberException: Public member osheet on type Workbook not found

What is wrong with that line of code?

 Dim oXL As Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet
        Dim oRng As Excel.Range
        Dim ValueTemp As String
        Dim oChart As Excel.Chart
        Dim MyCharts As Excel.ChartObjects
        Dim MyCharts1 As Excel.ChartObject

        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True

        ' Get a new workbook.
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet

        'Add a new Sheet.
        oSheet = CType(oWB.Sheets.Add(Count:=1), Excel.Worksheet)

        'change page orientation
        oSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape


        oSheet = oWB.Worksheets.Item(2)
        Dim intRowLoc, intcurrentrow, intCurrentCol, intLoop, intOuterLoop, intInnerLoop As Integer
        Dim boolRowFound, boolNextRow As Boolean
        intcurrentrow = 1
        intCurrentCol = 1
        For intInnerLoop = 0 To 135 'Column4.Count - 1
            ValueTemp = (Column4(intInnerLoop)).ToString
            oSheet.Cells(intcurrentrow, intCurrentCol) = ValueTemp
            

Open in new window

0
Is, at least some of, the thought of the .NET framework the ability to create a piece of software that doesn't require installation?

I would like to make a program that just runs. I have VS 2017.

I'm under the impression that I am correct... that is until you get to the point of using references that may need to be registered, etc.

At the end of the day I am familiar with C# and VB and would like to make a program that doesn't need to be installed and just runs. I would need to know the boundaries, or where the point is of "ok... now you have to install".

Thougts?
0
How can I add a series of 256 points to an Excel chart ? I have the code below however I can;t seem to find an add data property to the chart object?

Dim objApp As Excel.Application
        Dim objBook As Excel._Workbook
        Dim objBooks As Excel.Workbooks
        Dim objSheets As Excel.Sheets
        Dim objSheet As Excel._Worksheet
        Dim range As Excel.Range
        Dim chart As Excel.Chart

        ' Create a new instance of Excel and start a new workbook.
        objApp = New Excel.Application()
        objBooks = objApp.Workbooks
        objBook = objBooks.Add
        objSheets = objBook.Worksheets
        objSheet = objSheets(1)
        objApp.Visible = True
        objApp.UserControl = True
        'Add in Header Graph.
        objSheet.Shapes.AddPicture("C:\Header.png",
             Microsoft.Office.Core.MsoTriState.msoFalse,
             Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 50, 0, 45)
        'Add in DataChart

Open in new window

0
Hi

I have a byte array
byte[] newBytes

Open in new window


It contains
[0] 48
[1] 48

Open in new window


I know that this should equal 00
How do i get that into an int?
i've tried
var num = BitConverter.ToInt16(newBytes, 0);

Open in new window


but i get 12336 out of that
0
Hi there.

I have some code suggestion made for C#, that I want to make in VB.NET. Some code is meant to be in the "IdentityConfig.cs". Where is that going in VB.NET?

Best regards

Ulrich
0
Hi there.

I'm finally starting to step up to .NET. I will use a present classic asp project and redo from scratch. I want to implement two factor authentication (e-mail), but I'm unsure if it should be done in C# or VB, AND if it's only possible in one of these?
I'm used to VB from the past with classic asp, so of course I would like to use that, but two factor authentication is a must, so I'll have to deal with C# if necessary.
I look forward to your input. I found this:
https://www.hanselman.com/blog/AddingTwoFactorAuthenticationToAnASPNETApplication.aspx
It appears as C# to me. Am I wrong?
If you know of better guides/help to implement two factor authentication, please let me know. :-)

Best regards

Ulrich
0
What's the best way to parse the following string into an object?
vbCrLf & "+COPS: (2,""O2 - UK"",,""23410"",0),(3,""vodafone UK"",,""23415"",0),(3,""EE"",,""23430"",0),,(0-4),(0,2)" & vbCrLf & vbCrLf & "OK" & vbCrLf
An example would be good!
Thanks
0
Having issues with cut off data inside my COM port buffer. I keep things open for  5 secs. but it seems like a couple times it cuts off the front end of the message.

How can I protect against that. I do not use a STX start message or any Checksum or CRC's.
0
Hello Experts,
In the code below,  what happens to the value of Output parameter parm[1] and variable returnId inside and outside the USING block in C#?  Please try to help.

 { using (SqlConnection connection = SqlHelper.GetConnection())
     
               parm = new SqlParameter[2];
               parm[0] = SqlHelper.CreatePerameter("@Id", SqlDbType.VarChar, sId, ParameterDirection.Input, 50, false);
               parm[1] = SqlHelper.CreatePerameter("@Error_Msg", SqlDbType.VarChar, 0, ParameterDirection.Output, 500, false);

               returnId = SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.StoredProcedure, "usp_deleteRejectedItems", parm);
               strErrorMessage = parm[1].Value.ToString();
               intReturnId = returnId;
     }

    strErrorMessage = parm[1].Value.ToString();
    intReturnId = returnId;   

Open in new window


Thank you in advance for you time and help.
0
Hi
Following on from previous question

I have a TreeView and a ListView showing directory structure
The listView has Directories & files.

When I double click a Folder in the ListView how do I find the node in the TreeView and expand it replacing the contents of the ListView  similar to explorer

treeView1.Nodes  will only give you the Parent Nodes or in this case system drives

This Page suggest iterating through ChildNodes

In the full code bellow the bit  the handles double click is " ListView1_MouseDoubleClick"
When adding items to the ListView item.tag = the FullPath of the item e.g. "E:\\temp\\SubDir" or "E:\\temp\\SubDir\\MyFile.txt" I thought I could use this to find the TreeView.Node

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static DragDrop.NativeMethods;
using static System.Windows.Forms.ImageList;

namespace DragDrop
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            PopulateTreeView();
        }

        private void PopulateTreeView()
        {
            foreach (var drive in Environment.GetLogicalDrives())
     

Open in new window

0
I need to display birthdate value as age.

Examples:
DateTime bd1 = new DateTime(1, 5, 1);

string age1 = bd1.AsAge();

//output: 
// 1 Year, 5 Monthes, and 1 Day.

Open in new window


DateTime bd2 = new DateTime(50, 1, 30);

string age2 = bd2.AsAge();

//output: 
// 50 Years, 1 Month, and 30 Day.

Open in new window


The client asks for rounding the age value but she does not give me the rules.

Is there any ready component to use instead I reinvent the wheel?

Thanks
0
My Custom DGV returns zero for selectedRowCount.

        public int SelectedPatientId()
        {
            int selectedRowCount = dataGridViewEx1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            int id = -1;

            if (selectedRowCount > 0)
            {
                id = int.Parse(dataGridViewEx1.SelectedRows[0].Cells["Id"].Value.ToString());
            }

            return id;
        }

Open in new window


using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ECMS.Client.Desktop.Helpers;

namespace ECMS.Client.Desktop.Views.UserControls
{
    public class DataGridViewEx : DataGridView
    {
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Color BackColor
        {
            get => base.BackColor;

            private set => base.BackColor = value;
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Color ForeColor
        {
            get => base.ForeColor;

            private set => base.ForeColor = value;
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Font Font
        {
            get => base.Font;

            private set => base.Font = 

Open in new window

0
Hi
Following on from previous question

When loading directories in TreeView the  $Recycle.bin and System Volume Information directory  are shown See Picture
Clearly you don't want users to be clicking these

I thought about using a try catch block to handle the exception but then I thought it's probably better not to show them in the first place

The code snip bellow gives
Argument 1: cannot convert from 'System.IO.DirectoryInfo' to 'string' @ (d) 

Open in new window


        private void OnNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode newSelected = e.Node;
            listView1.Items.Clear();
            DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag;
            ListViewItem.ListViewSubItem[] subItems;
            ListViewItem item = null;


            var Directories = nodeDirInfo.GetDirectories()
                         .Select(d => new { Attr = new DirectoryInfo(d).Attributes, Dir = d })  // error here
                         .Where(x => !x.Attr.HasFlag(FileAttributes.System))
                         .Where(x => !x.Attr.HasFlag(FileAttributes.Hidden))
                         .Select(x => x.Dir)
                         .ToList();
            foreach (DirectoryInfo directory in Directories)
            {
                item = new ListViewItem(directory.Name, 

Open in new window

0

.NET Programming

134K

Solutions

39K

Contributors

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.