C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

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

Sign up to Post

Hi I am new to C# core and I come from a VB forms background.  I have been working on a web application project using the latest asp core.  

All i am trying to do at the moment is have a page where you enter a serial number then on leaving that serial number it comes back and displays some additional information from a stored procedure in a grid on the page or it displays an error from the stored procedure.  Then there is another button that will fire another stored procedure that will insert data into a database or return an error on error checks.   If not an error the whole page resets and ready for the next one.

The problem I have been having is that i cannot work out how to fire the stored procedure and return the data after leaving the text box and display an error if needed.  To simply it I have added a button so I enter the serial number then press the button rather than get the on leave event from the text box.

My problem is the data is binded before the page loads with some default data.  I do not know how to do it part of the way through or how to pass a parameter (serial number to it).  I have the ajax to call a function that displays the data from before, but i do not know how to change the lookup to be based on that serial number.  Or in the case of being an error display an error.

My code is below:
Model class:
public class OperationsData
    {

       public string Job { get; set; }
       public string Item { get; set; }
       public string…
0
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

I'm still learning so much about Xaml but one thing I currently need is a background that looks like alternating colors of grid rows like this:
GridlinesI'm reasonably sure I'd use a VisualBrush element to do this but I honestly have no idea how to construct the thing. I need a thin border between each "row" and every alternate "row" needs a different color.
0
Starting with some example code found at pdfsharp, I modified it to crate a bates stamp to an existing pdf. In this case it is just looking in a folder and combining any pdf's in the specified folder to make a new pdf, then adding a numbering system at the very bottom.

using System.Diagnostics;
using System.Collections;
using System.Globalization;
using System.IO;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing;

namespace ConcatenateDocuments
{
    /// <summary>
    /// This sample shows how to concatenate the pages of several PDF documents to
    /// one single file.
    /// </summary>
    class Program
    {
        static void Main()
        {

            Variant3();

        }

        /// <summary>
        /// Put your own code here to get the files to be concatenated.
        /// </summary>
        static string[] GetFiles()
        {
            var dirInfo = new DirectoryInfo("./results");
            var fileInfos = dirInfo.GetFiles("*.pdf");
            var list = new ArrayList();
            

            foreach (var info in fileInfos)
            {
                // HACK: Just skip the protected samples file...
                if (info.Name.IndexOf("protected", System.StringComparison.Ordinal) == -1)
                    list.Add(info.FullName);
            }
            return (string[])list.ToArray(typeof(string));
        }

        /// <summary>
        /// Imports all pages from a list of documents.
        /// </summary>


     

Open in new window

0
Trouble adding comma to bar graph data using Windows Chart Class

I am using the library:
System.Windows.Forms.DataVisualization.Charting

and found I could format (with comma) for values > 1,000

with this line of code:
ca.AxisY.LabelStyle.Format = ("##,#");

But, I can't figure out how to get the data to display also with the comma.

Best I get is the following:
Missing Comma on Data
Here is the Microsoft reference document:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.chart?view=netframework-4.0
0
I'd like to have a different appearance for an element when it's inside a StackPanel vs when inside another container. When in a StackPanel, I want the element to have a 5 pixel margin but not when inside other controls. Let Let me use the Rectangle object as an example. This might be the literal markup:
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Rectangle Grid.Column="0" Fill="LightBlue" Width="70" Height="30" HorizontalAlignment="Left"/>
    <Rectangle Grid.Column="1" Fill="LightCoral" Width="70" Height="30" HorizontalAlignment="Left"/>
</Grid>
<StackPanel Orientation="Horizontal">
    <Rectangle Fill="LightBlue" Width="70" Height="30" HorizontalAlignment="Left" Margin="5"/>
    <Rectangle Fill="LightCoral" Width="70" Height="30" HorizontalAlignment="Left" Margin="5"/>
</StackPanel>

Open in new window

But what I want is for the Margin attribute to automatically be set whenever the rectangle is inside the StackPanel rather than me having to explicitly state it every time I insert one. I'm sure Xaml styles can accomplish this but I'm not sure how. Can anybody point me in the right direction?
0
We have an AIX unix server we need to connect to and then run two commands using C# or something in SSIS. How can we do this? Ultimately we are working to automate what is currently a manual task for us.

cd /strbus/fw
sh job/edid2c
0
I have the following style template:
    <Style x:Key="PageButton" TargetType="ToggleButton">
        <Setter Property="Height" Value="38"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="4,0,0,0"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="Helvetica"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="Foreground" Value="{DynamicResource Page.Foreground}"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border Background="#FFF2F2F2" BorderBrush="Transparent" BorderThickness="4,0,0,0" >
                        <Grid>
                            <TextBlock Name="NormalText" FontWeight="Normal" VerticalAlignment="Center" Margin="10,0,0,0">
                                <ContentPresenter/>
                            </TextBlock>
                            <TextBlock Name="BoldText" FontWeight="DemiBold" VerticalAlignment="Center" Margin="10,0,0,0" Opacity="0">
                                <ContentPresenter/>
                            </TextBlock>
                        </Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>

Open in new window

0
i wrote c# script task to check a service is running on a remote server, but running the task generated error which doesn't really tell what's the real problem.
0
I'm trying to teach myself xaml. I'm starting to understand it but there is still so much to learn. I have a simple user control that is supposed to grow and shrink itself when a button is clicked. I want that grow and shrink to be animated. So far I have the shrink working perfectly but I have no idea how to trigger the grow animation if the control is already shrunk. Basically, I need a way to toggle between shrink and grow depending on the current width of the control. Can anyone help me modify my xaml to be able to do this?
<UserControl.Resources>
        <Storyboard x:Key="ShrinkMe">
            <DoubleAnimation Duration="0:0:0.5" From="300" To="30" Storyboard.TargetName="OverallDimension" Storyboard.TargetProperty="(Border.Width)" AccelerationRatio="0.2" DecelerationRatio="0.8"/>
            <DoubleAnimation Duration="0:0:0.5" From="1" To="0" Storyboard.TargetName="PageControl" Storyboard.TargetProperty="(Grid.Opacity)" AccelerationRatio="0.2" DecelerationRatio="0.8"/>
        </Storyboard>
        <Storyboard x:Key="GrowMe">
            <DoubleAnimation Duration="0:0:0.5" From="30" To="300" Storyboard.TargetName="OverallDimension" Storyboard.TargetProperty="(Border.Width)" AccelerationRatio="0.2" DecelerationRatio="0.8"/>
            <DoubleAnimation Duration="0:0:0.5" From="0" To="1" Storyboard.TargetName="PageControl" Storyboard.TargetProperty="(Grid.Opacity)" AccelerationRatio="0.2" DecelerationRatio="0.8"/>
        </Storyboard>
    </UserControl.Resources>

Open in new window

0
Hello i'd like to crate a function which will check string and if it's contains any of +.-.*./ ,^ these i'd like to get a boolean false from that function.

Is there anyway to do that simply or i had to create switch operator for each one?

Any help would be grateful.

Thank you.
0
Fundamentals of JavaScript
LVL 13
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I need to query an ASP.NET C # page using Delphi and the ICs overbyte TSslHttpCli component. I can get the login page with "GET" authenticate with "POST" but when making a query on an internal form using "POST" I am logged out with session expired.

I have a simple font doing the operations, who can help I send the fonts already working and showing where the error is.
0
I've code like below and the problem is if the excel file is opened it gives an error and saying it's using with another process i don't know why it's happening.


        private static bool CheckTemplateFoundInDb(string dbPath, string substrName, string templateName)
        {
            System.IO.FileStream filestream = new System.IO.FileStream(dbPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);

            var workbook = new ClosedXML.Excel.XLWorkbook(filestream);
            var worksheet = workbook.Worksheets.Worksheet(substrName);

            bool result = false;

            using (var excelWorkbook = new ClosedXML.Excel.XLWorkbook(dbPath))
            {

                var nonEmptyDataColumns = excelWorkbook.Worksheets.Worksheet(substrName).ColumnsUsed().Skip(5);

                foreach (var dataColumn in nonEmptyDataColumns)
                {

                    if (templateName == dataColumn.Cell(1).Value.ToString())
                    {
                        result = true;
                    }
                }
            }
            return result;
         }

Open in new window



Any help would be grateful.
0
Hello,
I have a big .net C# application (asp.net and windows forms) with source code, but it is loading slowly.
Any idea if there is a tool or software or a way to convert the .net assembly to native so it load faster and smoother?
Thanks
0
I've been a very long time Windows Forms developer and have done a fair share of web application development as well but until now I haven't bothered to learn WPF. I'm having a little trouble getting started.

I'm trying to create a layout that looks something like this sketch:
Basic layout
The top bar will contain some kind of title text and a dropdown menu button on the right. The left panel should be able to slide out of the way making more room for the main panel. I'd like the sliding effect to be animated with a few specific parameters.

1. I'd like the effect to be triggered by a mouse click on the arrow
2. I'd like the slide effect to decelerate
3. I'd like to have the background color fade to a different color during the slide
4. I'd like to be able to rotate the arrow so it faces the other direction
5. When the side panel is minimized, I want the click on the arrow to reverse the whole thing
6. I want to be able to apply all of this from a ResourceDictionary rather than use inline styles

I'm a bit lost so far. I'm beginning to understand the concepts but the syntax is eluding me. I'm pretty much 100% certain that I'll be doing some kind of storyboard animation but I haven't figured out how to apply such an animation from within a ResourceDictionary. Also, I'm not entirely sure what the different regions should be made of. I'll need to put things inside each of the regions. In fact, the left region will probably contain a UserControl that I …
0
We are working on a e-commerce portal that is built on Dot Net.

For faster response and scalability, we have implemented an ARR based Reverse Proxy and Disk Caching. The site is deployed on Windows server 2012 R2 standard & IIS version 8.5.96000. Origin & ARR Reverse Proxy, are on the same server as of now.

This works fine most of the time, except there are intermittent issues which we are unable to solve.

Again, on a staging site everything works well. But on production site with live traffic we are getting these issues:

net::ERR_CONNECTION_RESET 200 error. This gives me a blank page! This is again more frequent, but it doesn't come always. It comes when we are performing searches. Check the image here: https://i.stack.imgur.com/4m1kg.png

Moreover, for both of above error, if I just do a refresh, then it works fine!
0
I've a worksheet which has several columns with different size (row sizes are different) i'd like to find a column and iterate the rows that belongs to it. How can i do it ?

Any help would be grateful.

Thanks.
0
Hi do you know how to api Office 365 OneDrive with aspx/c# ?
For example, I just want to extract one folder called 'home' and list all files inside of home folder?

Thanks
0
Hi Experts,
 We have some folders where we have some text files.  From text file we generate the Weekly report. We manually open the files and get total documents numbers and Net amount to populate to Excel file. We would like to automate this one so planning for .Net application and schedule job so program can read those files and update excel file.

The requirement is to go to particular folder and open that txt file and gram total number of Document Number and Total sum of Net Amount and populate to Excel file.

I am attaching Text file as well as excel file. Can you please help me?

Sample_Textfile.txt
Output.xlsx
0
When i'm trying to run my tool on Debug or Release mode it's always loading symbols at startup.

Is that normal?

p2.png
0
Exploring ASP.NET Core: Fundamentals
LVL 13
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Hi All,

For my C# Win-form application, I have to restrict the manual entry using Keyboard . Only Bar-code scanner should be allowed.

Using below link, I am able to restrict the attached normal Keyboard, But not able to restrict USB or wireless keyboard, as properties of USB Keyboard and scanner are completely same.

https://www.codeproject.com/articles/17123/using-raw-input-from-c-to-handle-multiple-keyboardnow?fid=375378&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&fr=226&prof=True

I have also tried restricting keyboard on the basis of speed as typing speed using Keyboard will be slow than scanner but it is completely dependent on client's system speed hence was facing issue on same. Sometimes in few systems, it is restricting Scanner also when I use the speed concept.

Please help me on this.

Thanks.
0
I am running cefsharp/75. I want to turn on zooming with the ctrl key and the mousewheel. My event handler is never triggered. And if you hold ctrl and use the mouse will the screen doesn't move. So something inside the control and handling the event. Is there just a setting I am missing?
0
We are forwarding a bunch of data to different servers using HTTP CLIENT
These 3rd party servers vary in response time
Some respond in MS and some are taking up to 120 secs to respond
This slow response time is directly affecting our server performance and threads etc

One solution is to time out after N secs, but I was wondering if there was anyway to send the packet and not wait for a response
However i'm not sure if this is possible using HTTP CLIENT, or if there is a work around?
0
I’m planning to create a GUI for my application in WPF. I’m a newbie and would like to know do you creating controls on designer or creating on run time? and is there any logic to classify elements which will be create on run time and which will be designed on designer.
0
Free code sharing solution with edit history

I am looking for a free codesharing solution with edit history.  The service here is fantastic https://codeshare.io/GLDjbk. However, it allows anyone with the link to edit, doesn't provide edit history, and they start charging if you want to protect the code that you have written.

The language I am using is gscript based on Java and C#, but I would like to be able to put in any kind of code at all, even something not recognized.

Assistance in finding a better solution is greatly appreciated.
0
I have string value like below and i'd like to seperate what's the mathematical symbol +*-/ etc. and what is the other thing used in my mathematical equiation for example;

$_3D_R_wheel*2

$_3D_R_wheel is variable starts with "$"sign it's  multiplication because "*" and it multiplies with 2.

First i would like to achieve that.

After that if i have multiple variables and multiple calculations is it possible to do that?

($_3D_R_wheel + $_3D_R_rim) / 2

Any help would be grateful.
Thank you.
0

C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).