.NET Programming

133K

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

I'm getting an exception in my following line of code in my function.  My goal is to return the value of my resultsContainer if my switch statement is invoked.

            results = resultsContainer;  > Cannot implicit convert type System.Collections.Generic.List<XXX.Models.CustomReports.CreditHoldDetailsResults>
to xxx.Models.CustomsReport.CreditHoldResultsContainers.


    public static CreditHoldResultsContainer GetReportResultsObject(CreditHoldSearchCriteria searchCriteria
            , xxx.Models.Employee LoggedInUser
            , System.Globalization.CultureInfo systemCultureInfo
            )
        {
            var results = ServiceAssistantService.CustomReports.CreditHoldService.GetReportResults(searchCriteria, LoggedInUser.CultureInfo, LoggedInUser.ID.Trim().ToUpper());
            var resultsContainer = results.reportResults;
            var headerText = "";

            
         
            if (resultsContainer != null && resultsContainer.Any())
            {
                headerText = headerText + "  " + Sxxx.Tools.Language.Translate(Language.Keys.Sort_By, LoggedInUser.CultureInfo) + " : ";
                switch (searchCriteria.SortOrder)
                {
                    case 1:
                        resultsContainer = resultsContainer.OrderBy(x => x.CustomerNumber).ToList();
                        break;
                    case 2:
                        resultsContainer = resultsContainer.OrderByDescending(x => 

Open in new window

0
OWASP: Threats Fundamentals
LVL 12
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

I am checking if a particular user is in the database if not i want to popup a error which says not in the database but the method runs over the error and does not popup.

protected void Page_Load(object sender, EventArgs e)
        {
          
            if (Session["ISADMIN"] == null)
            {
                isAdminUser();
            }
          
                userrole = Session["USERROLE"].ToString();
                userplant = Session["USERPLANT"].ToString();
            
        }

 public void isAdminUser()
        {
           string con = ConfigurationManager.ConnectionStrings["OEEDBConnectionString"].ToString();
            string username = System.Web.HttpContext.Current.User.Identity.Name.Substring(System.Web.HttpContext.Current.User.Identity.Name.LastIndexOf(@"\") + 1); // Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1);             
            string IsAdmin = "NO";
            using (SqlConnection sqlcon = new SqlConnection(con))
            {
                try
                {
                    sqlcon.Open();
                    SqlCommand mycmd = new SqlCommand();
                    mycmd.Connection = sqlcon;
                    mycmd.CommandText = "SELECT [User Id], Role, Plant FROM [WasteUsers] with (nolock)  WHERE [User Id] =" + "\'" + username.ToLower() + "\'";
                    mycmd.CommandType = CommandType.Text;
                    SqlDataReader myrdr = mycmd.ExecuteReader();

Open in new window

0
I want to disable a dropdown in my cshtml code

<dropdown dropdown-menu-items="results" option-label="Not Reviewed" class="jq-checker-inspection-dropdown" data-poi-index="@inspectionItem.PointOfInspection"></dropdown>

I tried disabled = "true" and that does not work.

I also have a boolean variable
isenable = false

and i tried something like this

<dropdown dropdown-menu-items="results" option-label="Not Reviewed" class="jq-checker-inspection-dropdown" data-poi-index="@inspectionItem.PointOfInspection" @(isEnabled ? "disabled" : "")></dropdown>

None of them work. can you please suggest on how i can diable the dropdown box.
0
using microsoft visio 2013 standard how to draw various diagram like below
1. sequence diagrams
2. flow diagrams
3. activity diagram
4. user interaction diagrams
5. database diagrams
6. any other similar type of system, system flow diagrams

any good video tutorials, resources, , links around this?
please advise
0
I have a dropdown in my cshtml file and and need to disable and enable it based upon a variable value

var canEdit = false or var canEdit = true

so basically if value is false disable the dropdown or if true enable the dropdown

<dropdown dropdown-menu-items="results" option-label="Not Reviewed" class="jq-checker-inspection-dropdown" data-poi-index="@inspectionItem.PointOfInspection"></dropdown>

I want it to work that something like this

 <input @(isEnabled ? "" : "disabled") @(noId == savedId ? "checked" : "") class="form-check-input" type="radio" name="checker-verify-radio-@componentId" id="checker-verify-radio-no-@noId" value="no">

the above working code is for a check box.if its true i have the checkbox checked and if false then checkbox is unchecked.

similiarly i want to have my dropdowd disabled if canEdit = false  and dropdown enabled if canEdit = true
0
Hi,
What is the meaning of Annotate (Blame) in GitHub
I am using visual studio 2017.

Thanks in advance.
0
Following on from @ gr8gonzo  comment here on serialize and deserialize XML

This will test if a show exist before adding it

            if(tv.Shows.Exists(show => show.TMBDBid == 77236))
            {
                Console.WriteLine("A Discovery Of Witches Exists");
            }
            else
            {
                tv.Shows.Add(new Show()
                {
                    Name = "A Discovery Of Witches",
                    FolderName = "A Discovery Of Witches",
                    TMBDBid = 77236



                });
            }

Open in new window


How do I test if an episode exists

Tried this but both produced errors so didn't  continue  with  Episode.EpisodeNumber etc
if (tv.Shows.Exists(show => show.TMBDBid == 67133 && show.Season.SeasonNumber))

// AND this
if (tv.Shows.Exists(show => show.TMBDBid == 67133 && show.Season => Season.SeasonNumber))

Open in new window


Again expanding on the example  How do I list the episodes?

         foreach (Show show in tv.Shows)
            {
                // Print out what TV shows are listed

                string ShowName = show.Name;
                string ShowID = show.TMBDBid.ToString();
                Console.WriteLine("ShowName: {0}, TMBDBid: {1} ", ShowName, ShowID);
                foreach (Season season in show.Season)
                {
                    String SeasonNumber = season.SeasonNumber.ToString();
                    Console.WriteLine("SeasonNumber: {0}", SeasonNumber);
                }
                foreach(Episode episode in show.season.)
                {
                    // How do I list the episodes?
                   //                Error	CS1061	'Show' does not contain a definition for 'season' and no extension method 'season' accepting a first argument of type 'Show' could be found
                }
            }

Open in new window


Also when adding a new show or episode can you add it in order of show name then SeasonNumber and finally EpisodeNumber
0
Example of Web Tokens

I am sure I have worked with these, but please give an overview.

Also, it would great if you could also include a .NET perspective

Thanks.
0
Need a quick overview of WebAPI.

I am a .NET Full Stack developer and have supported numerous web services, but have difficulty answering interview questions about WebAPI.

Please refresh my memory.

Thanks
0
Quick overview of JSON tokens

please provide me a few sentences to explain JSON tokens. I have worked with JSON on various full stack positions, and wonder how JSON tokens fit in.

Thanks
0
Python 3 Fundamentals
LVL 12
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Hi

When I try to run my ASP.net web app in debug mode I get the following message.
I am using Visual Studio 2017 Professional. How do I fix this?

1
0
visio 2013 standard does not show the "UML Sequence" template as shown below
https://www.youtube.com/watch?v=_xtZIDI8Ajg
only professional viso 2013 shows it?
are there existing sample diagrams which i can use as sample and modify on top of them easily?
any alternate tool to draw these type of diagrams easily apart from visio like free open source tools?
Please advise
0
how to understand big new project code quickly and effectively to write new enhancement to existing code or to fix some defects or to debug to improve some areas of poor performance.

what are the tips and recommendations , best practices around this
Please advise
0
I am working in a C#  application

I have constituted  a List with the script Below:

StaffNameListBox.DataSource = GlobalConfig.Connection.GetEmployees_All();
StaffNameListBox.DisplayMember = "FullStaffName";

 public string FullStaffName
        {
            get
            {
                return $"{Staff_no}  { Surname } {Firname }";
            }
        }

(See  the Screen of The list below showing a record in the list

On the Click event on this record I want to return a part of the string (ie just the staff_no)

 to a text box on the screen.  The name of the textbox is StaffNoValue


My click event syntax  is as below:

  private void StaffNameListBox_Click(object sender, EventArgs e)
        {
            StaffNoValue.Text = StaffNameListBox.ValueMember;
        }

What I want Returned to the text box on screen is as shown below

StaffNoValue.Text = "N001"

How can I get a portion of a list returned into a field using the actual name with which the list was loaded

and not by searching for a sub string of the selected item

Thanks
Selection-From-List--11-01-2019.PNG
0
what is difference between below two eclipse short cuts

control +alt+h
(above does not yield any results saying members calling that method in workspace it shows at bottom again same method nothing else)

control +shift+g
(above shows like 8 references in workspace)

please advise
shortcut.png
0
Hi,

I am having .wsdl url. I am having these two information

1. SERVICEendPOINT: http://service.com/geocode2008?wsdl
2. WSDL location url: http://service.com/provider/geocode/2008/

How to use these in c# .net application. How c# client consumes this .wsdl? I have attached my .wsdl in the attachment.

If I enter Zipcode, How to call getGeocode? I am not sure what needs to be done.

Thanks
wsdl_xml.jpg
0
Our operations process involves generating reports which are manually uploaded to a client website.  The users doing the upload are supplied a digital certificate to authenticate, so they have two factor authentication with the certificate, and the passphrase to use the cert when they log in to the client website.

I am wanting to automate this chore.  The client is willing to work with us, but we would have to supply him with our digital certificate for authentication onto his server. The goal is for an automated process to run the reports and upload them every night.

I know this is a common thing, and there are literally dozens of solutions. But I have not previously been asked to do this, so I qualify as noob here.  I'm looking for some feedback on what makes a good, reliable, and most of all, EASY TO USE certificate authority for this.  Suggestions for how to implement welcome!
0
I'll explain in steps what happened...

1. My manager moved the production database to a new server. It went from server YYY to XXX, for example
2. He changed the webconfig on the server to point to the new database. All good so far.
3. I wanted to update our production webserver with the new code. I don't publish directly to the server. I publish locally and just copy the Bin folder to prod (along with whatever files like JS, etc)
4. This is the publish settings:
p1.png
5. I published locally in Release mode. Copied the Bin folder. I didn't replace the webconfig on the production webserver. It was pointing to the correct database XXX.
6. I went to the site and the site was down with an error that looked like it was a connection to the database.
7. This is what I did to fix it. I went back to the code and in the Web.Release.Config, I saw the connection string as being the old one; YYY. I changed the connection string to XXX (new one). Compiled, published, copied the Bin folder and this time it worked. Note that I didn't replace the Production webconfig file
p2.png
So, how does this work... I didn't replace the webconfig on the prod server, I only changed it locally, compiled , republished and only copied the Bin folder.
0
Hello,
How to find the index of the item in the listbox.

Dim items = From i In lstbox.Items Where i.ToString().StartsWith("Al")

        If items.Count > 0 Then

        Else

        End If

Open in new window

0
OWASP: Avoiding Hacker Tricks
LVL 12
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Hi,

I have this scenario I want to achieve:

The user has logged in to his website (an adminstrative site).
Now he wants to open and login to another website that contains reports and it's a typical loginform. Loginform
Instead of needing to login to this second site he wants the administrative site to automatically log him in.

So my question is:
Is it possible to store the credentials in the administrative site and then do some sort of request to the second. report site, without the need for the user to manually login to two sites?
And, if it's possible, how can I achieve it?

Thanks for help!

Peter
0
Greetings:

I created an ASP.NET page with VB.NET page behind. This page display 4 images. There are 3 buttons below each image to rotate the image. When a button is clicked to rotate an image, the code behind loads the image into a bitmap variable; rotates the image; saves the image using the same name. The image is then reloaded to the page.

I'm experiencing intermittent success when rotating the pictures. I am a novice when it comes to the drawing classes within the .NET framework.

The ASP.NET page is:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="GraphicRotate.aspx.vb" Inherits="GraphicRotate" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Graphic Rotate</title>
</head>

<body>

    <form id="form1" runat="server">

		<br />
		<br />
		<asp:Label ID="lblMessage" runat="server" Text="No Error"></asp:Label>
		<br />
		<br />

		<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/IMG_3001.JPG" />
		<br />

		<asp:Button ID="Button1" runat="server" Text="Rotate 90 Clockwise" />
		<asp:Button ID="Button2" runat="server" Text="Rotate 90 Counter Clockwise" />
		<asp:Button ID="Button3" runat="server" Text="Rotate 180" />
		<br />
		<br />
		<br />

		<asp:Image ID="Image2" runat="server" ImageUrl="~/Images/IMG_3002.JPG" />
		<br />

		<asp:Button ID="Button4" runat="server" Text="Rotate 90 Clockwise" />
		<asp:Button ID="Button5" runat="server" Text="Rotate 90 Counter Clockwise" />
		<asp:Button 

Open in new window

0
Why might I getting this error. I am trying to connect to a DB from a console application and get this error.
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

Imports System.Data.Entity

Module Program

    Dim people As IEnumerable(Of Person) = New List(Of Person)

    Sub Main(ByVal args As String())
        Using context = New EFDbContext() '<--- Error here
            Dim repo As ITestRepository = New EFRepository(Of EFDbContext)(context)

        End Using

    End Sub
End Module

Public Class EFDbContext
    Inherits DbContext

        Public Sub New()
            MyBase.New("name=EFDbContext")
        End Sub

    Public Property People As DbSet(Of Person)

End Class

Open in new window

0
I had this question after viewing How to Save Database Connection info with Crystal Report Version 11 for Use on Business Objects Server.

I have a Crystal Report v 11.5ish that I want to send to a conversion company but I'd like to delete the Database information for security reasons.  However, when I try to delete it or replace info with junk, it attempts to make the connection and then fails.  How can I remove those details?
0
I have a following class class Result.
 
public static class Result
    {
        public static List<string> fromDifferentClass = new List<string>{ "cat", "dog", "bear" };
    }

Open in new window

And I am accessing this fromDifferentClass list in a different class.

class Program
    {
        static void Main(string[] args)
        {
            List<string> myList = new List<string>();
            myList = Result.fromDifferentClass;
            Console.WriteLine("Result: " + Result.fromDifferentClass.Count); // prints 3
            Console.WriteLine("myList: " + myList.Count); // prints 3
            Result.fromDifferentClass.Clear();
            Console.WriteLine("Result: " + Result.fromDifferentClass.Count); // prints 0
            Console.WriteLine("myList: " + myList.Count); // prints 0

            Console.Read();
        }
    }

Open in new window

in Program class, I made myList to refer fromDifferentClass.
And I cleared fromDifferentClass list.
so I understand myList also is cleared.
However, is there any way I can still keep the content of myList even after fromDifferentClass list is cleared();
So the currently the result is
3
3
0
0
But I want it to be
3
3
0
3
0
I have an MVC Web application. On the cshtml page, I have a data table that I am trying to format a date like M/dd/yyyy. My issue is that when the date is null, it displays "1/01/0001". I would like for it to just display blank if it is null. My code is below.

                            <td>@jobinfo.MLR_Submission_Date.ToLocalTime().ToString("M/dd/yyyy")</td>

Open in new window

0

.NET Programming

133K

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.