Questions tagged [c#]

C-Hash (pronounced "C-dialect") is an advanced, statically typified programming language with versatile paradigms crafted by Microsoft. C-Hash code typically serves the purpose of Microsoft's assortment of tools and runtimes such as .NET, .NET Framework, .NET MAUI, and Xamarin. Feel free to employ this label for inquiries pertaining to coding in C-Hash or its official specifications.

Setting Up PhpMyAdmin with NGINX on Windows

After embarking on setting up a server with NGINX today, I successfully configured PHP and MySQL. Everything seems to be going smoothly so far. However, I am facing an issue with getting NGINX to open PhpMyAdmin (previously located in the root directory [E ...

The callback for the Ajax request failing before entering the webmethod function

Below is the Ajax request I am using: $.ajax({ type: "POST", url: "ProductDetail.aspx/AddCart", data: '{productId:' + 4 + ',productTypeId:' + 0 + ',quantity:' + 1 + '}', contentType: "application/json; char ...

Unable to convert the current JSON object (for example, {"title":"content"}) into the specified type 'System.Collections.Generic.List`1`

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Facebook; using Newtonsoft.Json; namespace facebook { class Program { static void Main(string[] args) { var client = new Facebo ...

Ajax TabContainer TabPanels disrupt postbacks

Hey everyone, take a look at this ... <asp:TabContainer ID="jkhgjkgh" runat="server"> <asp:TabPanel ID="jkkljhgh" runat="server" HeaderText="sdkl;fgjl;kgjdf"> <ContentTemplate> <asp:Button ID="jhgkjgh" runat="s ...

Parsing error occurred while processing JSON data

After countless attempts, I still can't seem to properly parse this JSON data. The code I am using for parsing is as follows: var client = new WebClient(); client.Headers.Add("User-Agent", "Nobody"); var response = client.DownloadString(new Uri("https:// ...

Exploring intricate binding expressions using IF statements in ASP.NET

I am trying to create an expression for a column in my repeater, but I am not confident about the syntax. My goal is to display "No Document" if the value is equal to "DispForm.aspx", otherwise show the actual value. I attempted to combine all expression ...

Validating JSON in C# using Regular Expressions

In the scenario that I am presented with a JSON string and need to validate it using C#, it is important to understand the structure of a JSON string. The format typically looks like this: string jsonStr = {"Id":123,"Value":"asdf","Time":"adf","isGood":fa ...

What is the best method for encrypting a URL that contains AngularJS data?

Here is the URL that needs to be encrypted: <a class="btn btn-success btn-sm btn-block" href="@Url.Action("myAction", "myController")?Id={{repeat.Id}}&HistoryId={{repeat.HistoryId}}" ng-cloak>View History</a> I am seeking guidance on enc ...

Specflow tests failing to start

I've encountered an error while trying to execute my Specflow tests. Despite various attempts like deleting the bin, removing all NuGet packages and reinstalling them, and making changes to the app.config file, this error continues to persist. Test N ...

Tips for successfully retrieving a boolean value from an ASP.Net JavaScript AJAX request using a C# method

Query: Is there a way to call a C# function from JavaScript code on an .aspx webpage to get authentication results based on a username and password? Here is the JavaScript AJAX POST request I am currently using: $.ajax({ type: "POST", ...

Issue encountered with Selenium WebDriver in C#: Unable to successfully click on a hyperlink within a frame

Currently, I am utilizing Selenium Webdriver for automation in C#. Within my application, upon clicking on a specific link, a frame is opened on top of the main browser window. I am able to successfully read text within that frame and switch to it as neede ...

Converting plain text to HTML in emails using Outlook

Trying to figure out how to maintain the formatting of plain text email while displaying as virtual plain text in C sharp, specifically when receiving in Outlook 2007 with VSTO. The current code is not preserving the original formatting, instead it changes ...

Trouble integrating JSON data with Newtonsoft.Json library in WPF applications

Currently, I am working on extracting data from the office365 API that returns responses in JSON format. My aim is to store specific data such as Id and DisplayName into variables for further use, but I seem to be struggling with the process. I came across ...

Is it possible for additional JSON properties to be deserialized into a JObject within a class during the deserialization process?

Imagine we are working with the following JSON data: { "apple": 5, "banana": "yellow", "orange": 10, "grape": "purple", } and a C# class is defined as: class Fruits { public int AppleCount { get; set;} public string BananaColor ...

Is there a way to convert NuGet.NuGetVersion to a class in C# through deserialization?

As a novice programmer working on an application for my job, I recently encountered an issue while trying to deserialize a class. The class in question is named Nuget, and its structure is as follows: public class Nuget { public string? Name { get; set ...

Retrieve JSON data from a web API and transmit it to a partial view using a controller

Currently, my code is set up like this: public ActionResult Search(SearchModel model) { string url = "http://10.0.2.31/testwebapi/api/data"; WebClient wc = new WebClient(); wc.QueryString.Add("forename", model.Forename); ...

Ensuring Accuracy of Error Messages with Selenium WebDriver

Could use some help with validating error message text in a try-catch block. It seems to be catching every time, looking for advice on the syntax or a better approach to validation. string actualResultText = ""; string expectedResultText = " ...

Switching from MSTest to NUnit: Exploring NUnit's alternatives for CurrentTestOutcome and UnitTestOutcome

I need assistance converting the code below from MSTest V2 to NUnit 3. Can someone help me identify the alternatives for CurrentTestOutcome and UnitTestOutcome in NUnit? var status = MyTestContext.CurrentTestOutcome; switch (status) { case UnitTestOu ...

The issue with triggering button events in JavaScript

I've integrated a jquery modal popup for saving uploaded files related to a specific device. The modal appears, the cancel button functions correctly, but I am struggling to trigger the onclick event for the Save button... This is what I have implemented: ...

c# Selenium WebDriver - Steps to turn off Facebook Page notifications

I'm relatively new to using Selenium WebDriver and I've encountered an issue with a notification popping up on Facebook while attempting to log in. Despite searching extensively, I haven't been able to find a solution that works for me. I ca ...

Steps for uploading an Excel file in an MVC controller

Currently, I am attempting to upload an Excel file using AngularJS + MVC. The view consists of an HTML file with a basic HTML file upload functionality. Once the file has been uploaded, my goal is to be able to access the Excel file within the MVC controll ...

Submitting an ASP.NET MVC form with jQuery and passing parameters

Having trouble passing the ThreadId parameter when submitting a form to my controller through jQuery Ajax. The code works fine, but for some reason, the ThreadId doesn't get passed using form.serialize(). Any suggestions on how to effectively pass par ...

Troubleshooting: Issue with WCF service not processing POST requests

I encountered an issue when attempting to call a WCF service using AJAX from another project. The error message displayed was: The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message ...

In what way can I decipher a section of the URL query string within my AngularJS application?

Here is a snippet of code that I am working with: var search = $location.search(); if (angular.isDefined(search.load) && search.load != null) { if (search.load = "confirmEmail") authService.confirmEmailUserId = search.userI ...

The perfect pairing: Visual Studio and Gulp

Having trouble running Gulp in Visual Studio for an angular app, I encountered the following error message: Cannot evaluate the item metadata "%(FullPath)". The item metadata "%(FullPath)" cannot be applied to the path "node_modulesgulp ode_modulesgul ...

One approach to returning multiple objects based on a column with multiple values in Dynamic Linq

Situation: I am facing a task where I need to export an excel file containing a list of Parts. Users have the ability to select specific columns and only retrieve data from those selected columns in the exported file. To handle this dynamic report, I have ...

In C#, is there a way to conceal the Selenium Webdriver console application while also specifying a unique path for the drivers to be located?

I need to achieve two specific tasks with Selenium-Webdriver: hiding the console that pops up and specifying a custom path for the driver's location and version. Unfortunately, I couldn't find a constructor that can handle both a string for the directory ...

Changing a List object into a JSON string in C#

Struggling to convert a List object to a Json string has been a major challenge in my ASP.net MVC project. Model: public class PagerBase<T>:List<T> where T:EntityBase { public int totalpage {get;set;} public int pageindex {get;set;} ...

Leveraging WebApi for ADFS authentication

We are currently working on setting up the following scenario: An HTML page sends an AJAX request to a WebApi inquiring about whether or not a user has a specific role. The WebApi then checks with ADFS to see if the user is logged in (if not, it authentic ...

Code for dividing large JSON data based on node names in a generic way

I am facing a challenge with handling very large JSON files, where the car array can contain up to 100,000,000 records. The file size ranges from 500mb to 10 GB and I am currently using Newtonsoft json.net for processing. Input { "name": "John", "age": " ...

Is there a way to navigate to the "Error" view page following an AJAX request?

Currently, I am utilizing an Ajax function to call an HTTP Post Action method located in the controller. During this process, the action method is producing a basic exception message. To address this issue, I have applied my own personalized handler attr ...

Unable to access the Newtonsoft.Json file or assembly

My current project involves using Json.net in c# to create a json file. After building the code successfully, I managed to generate the parser.exe file without any issues. However, when attempting to run this parser.exe on a different server where it is in ...

Adding Information to Mongodb with C#

using MongoDB.Bson; using MongoDB.Driver; protected static IMongoClient client; protected static IMongoDatabase db; public async void Insert() { client = new MongoClient(); db = client.GetDatabase("Database"); str ...

Delete the "img" and "a" elements from the content within the specified node

Is it possible to only extract text from my HTML content? var sb = new StringBuilder(); doc.LoadHtml(inputHTml); foreach (var node in Doc.DocumentNode.ChildNodes) { if (node.Name == "strong" || node.Name == "#text" || node.Name == "br" || no ...

How Can I Utilize a URL Parameter Twice to Execute SQL Queries in Two asp.DataLists on a Single Page?

I've been trying everything, but I just can't seem to get one query to function properly. My goal is to retrieve information from the SQL Server database in two separate queries - one for album names (based on URL parameter) and another for song ...

Effective methods for accessing and updating text editor values using Selenium

I am currently working on a web page that has a text editor, and I need to populate its value using Selenium scripting in C#. I have successfully done this for a textbox following instructions from Set value in textbox. However, when attempting the same pr ...

Error: The PerfSDK single user is missing the essential c# assemble

After reviewing documentation, I attempted to create a performance test for AX 365. Unfortunately, I encountered an issue while trying to build the project in VS 2015 because I am missing the assembly 'MS.Dynamics.TestTools.DispatcherProxyLibrary.Appl ...

Transmit intricate json data through a concealed variable and retrieve it in an mvc 3 controller

I am looking to achieve the following task. Encode a complex JSON object and store it in a hidden input variable. Retrieve the hidden variable using the form collection object. Transform the hidden text value into a dynamic object for seamless data retri ...

The efficiency of WebMethod decreases

Currently, I am working on a basic JavaScript AJAX request using jQuery: $.ajax({ type: "POST", url: "TabbedSummaryPage.aspx/RunReport", data: "{'itemId': '', 'lType': '', 'reportId': '&ap ...

Selenium struggles to identify checkbox with intricate attribute definition

I have encountered an issue with locating a checkbox on the web application that I am writing Selenium scripts for. Despite my efforts, the script seems unable to find this particular checkbox. Here is a snippet of my code: WebDriverWait wait = n ...

What is the best way to extract text from a div element?

I'm attempting to extract text from a div and save it in a text document using Selenium with C#. I'm facing an issue where I can't retrieve the text from the div and store it in a variable. <div data-tid="messageContent" dir="auto">&l ...

What is the proper way to transfer information to my ajax function from my controller?

I need to dynamically update an element on my webpage based on server-side code events. For example, when I trigger the "Start" function by clicking a button, I want the text inside a specific element to change to "Downloading", and then once the process i ...

C# - Issue with Webbrowser failing to fully load pages

I am facing an issue with loading pages completely on the web browser, likely due to heavy usage of JavaScript. To address this problem, I have integrated another browser into the project called Awesomium. I am wondering if Awesomium supports using getEle ...

Enhancing JSON data by incorporating new key-value pairs

I need help converting a CSV file into a JSON file using C#. The issue I am facing is that the JSON generated contains only values without any keys. I want to convert it into a key => value format for better organization. Below is my current code: static ...

Introducing the Generic DefaultWait for Webdriver

In my IDriver class, I am looking to implement a method like the following: this.driver.WaitUntil(x => LoginForm.Displayed, TimeSpan.FromSeconds(5)); this.Driver is an IDriver field The current implementation does not wait for element to be displayed ...

Is it possible to implement a real-time data update feature in a Gridview using ajax in C#

I've been working on updating my gridview automatically with the latest data using ajax in c#. I attempted to create an ajax post that calls my c# method, fetches the updated data, and then binds it to the gridview. However, I'm facing an issue where the d ...

Comparing screens through automated testing

Currently utilizing Webdriver in conjunction with C#, one major challenge is that Webdriver cannot test design elements. Therefore, I am exploring the idea of implementing a screenshot comparison tool. Given that I am working on a large website with freque ...

Is it possible for me to utilize this code for logging in through a dialog box?

Here is the code snippet I have on the client side: <p>Username:</p> <p><asp:TextBox ID="tbUsername" runat="server"></asp:TextBox></p> <p>Password:</p> <p><asp:TextBox ID="tbPassword" runat="server ...

A guide on retrieving and resetting the value of a radio button within a table

I need to create multiple radio buttons within a table using Razor syntax under ASP.NET Core MVC. Each row of the table should have an update and clear link to update the record and clear the selected radio button for that specific row. <table class=&qu ...

Implementing a file size restriction in C# when writing a lengthy JSON string using the System.IO.Stream

I have a large array stored in Json format, and the result is saved in a variable called "sz" (string). However, when I attempt to save this Json result (string sz) to a file, it seems that not all of the string gets saved. Why is this happening? The siz ...

The combination of Angular JS, Cross Domain, and Web API is a powerful

I'm looking to integrate Angular JS with Web API for my application. Technologies: Visual Studio 2013, .NET 4.0, Microsoft Server 2003. My Web API and Angular JS Client are on separate domains [Required]. I attempted to implement this using .NET 4.5 ...

Leveraging LINQ to JSON for extracting distinct elements from a collection

Having trouble organizing a list of objects/values from a JSON feed using LINQ? Here is what my JSON feed looks like: { "Project":[ { "ID":"XY1212", "Name":"Some Name", "Description":"U.S. No 2 Diesel Retail Prices", ...

Regular Expression for valid Mobile Phone Number country code starting with 0092 or +92

Have you come across a standardized regular expression that captures all valid mobile phone numbers, such as 00923465655239 or +923005483426? I've been searching for it for two days but haven't found an expression that fits these formats. The co ...

Implementing conditional button visibility in Angular based on user authorization levels

I've been experimenting with the following code snippet: <button ng-if="!isAuthenticated()" ng-click="deleteReview()">Delete</button> In my JavaScript, I have: $scope.isAuthenticated = function() { $http.get("api/user/getA ...

Get rid of the percentage displayed in the tooltip of a Google Pie Chart

Is it Possible to Exclude the Percentage from Google Charts Tooltip? For instance, I am looking to eliminate the display of 33.33% in the tooltip and only show the value itself. ...

Decoding Json data in C# using JSON.NET

I am currently working on a C# application that retrieves the backpack value of players in a game called TF2 using Backpack.tf's API. Here is a snippet of the code: (MAIN CLASS) JsonConvert.DeserializeObject<Json1>(json); (END OF MAIN CLASS) ...

Exploring the Interplay of JSON Objects in SQL Server and C#

After executing the following SQL Server query, I successfully created a JSON object: SELECT Attribute 1, Attribute 2, Attribute 3,... AS Identifier FROM Table_1 tbl1_obj INNER JOIN Table_2 tbl2_obj ON tbl2_obj.Id = tbl1_obj.Id FOR JSON AU ...

Sending JSON Data from C# to External JavaScript File without Using a Web Server

Trying to transfer JSON data from a C# (winforms) application to a static HTML/JavaScript file for canvas drawing without the need for a web server. Keeping the HTML file unhosted is preferred. Without involving a server, passing data through 'get&ap ...

Exploring the Power of AngularJS Directives within MVC 5.0

Is there a way to implement the [numericOnly] directive in a textbox using Razor? @Html.TextBoxFor(m => m.salary, new { data_ng_model = "salary" }) app.directive('numericOnly', function () { return { restrict: 'A', require: '?ngMo ...

Deactivate the other RadioButtons within an Asp.net RadioButtonList when one of them is chosen

Is there a way to disable other asp.net radio buttons when one of them is selected? I have three radio buttons, and I want to disable the other two when one is selected. After doing some research, I managed to disable the other two when the third one is se ...

An unanticipated JSON token encountered while parsing the DataTable

Here is the json string that I am working with: { "Orders": [{ "SubOrderNo": "0582715", "ItemNo": "20415541", "ItemType": "ART", "ItemName": "Fish", "TemplateName": "TP1234", "ObjectType": "MPP", ...

Error in .NET when deserializing a missing member

There's a library I'm using with a custom exception, but I've encountered an issue. The custom exception code is as follows: public class CustomException : Exception { public CustomException(string message) : base(message) { } } The library i ...

Create an API using asp.net MVC technology within a web application framework

I have a MVC 3 Web Application with approximately 50 Views. I am curious if it is feasible to incorporate an API alongside these Views without any complications. In my ideal scenario, the server would be operational and every request would be directed to ...

Extract JSON elements from a massive document

Looking for a way to update a JSON file in C# by deleting specific data sets? Check out this example below: [ { "ID": "ID0000001", "Name": "ABCD", "Std": "4" }, { "ID": "ID5335355", "Name": "JKLM", "Std": "6" }, { "ID": "ID5353 ...

Develop a nested json object within another json object and send it back to Ajax

In my c# code, I am currently working with a List of Translations structured like this: public class Translations { public string en { get; set; } public string de { get; set; } } Now, I need to convert it into a Json Object because the function ...

How to Click a Button Using Selenium without Specifying ClassName or ID

I am working on a project related to Browser Automation, but I'm encountering issues with clicking a specific button. I attempted the following steps: webDriver.FindElement(By.XPath("//*[@id='uploadForm: fileup']/div[1]/button[1]")).Click(); webDriver.Ele ...

Is it possible to apply WebDriverWait on an element that has already been set?

I'm currently developing an automation framework that embraces the Page Object Model (POM), and within my project, there is a class file named HomePage. In this class, I have already defined an element using: [FindsBy(How = How.Id, Using = "TextField1")] ...

Using C# Selenium WebDriver to efficiently locate hyperlinks based on several specific strings, all while incorporating a reference within the string

I am trying to click a link using two different strings. However, the code I have tried does not seem to be working. Can anyone provide any guidance? var xPathString = String.Format("//a[contains(text(), 'Enforcement') and contains(text(), '{0}')]", ...

Ways to securely store passwords in Selenium WebDriver using C#

Currently, I am working on enhancing our website automation testing script. We have a team of part-time staff members whom we rely on to run this script in order to monitor all our web services. However, there is a security concern that arises before dele ...

Struggling to create an ExtentReport for your .NetCore App 2.1?

I am currently working on a project in .NetCore App 2.1 and have created some selenium scripts in C# using the NUnit framework on MacOS. The execution of these scripts has been successful, but I am facing difficulties generating a report using Extent Repor ...

Looking for a script to automate clicking on a specific web element using JavaScript

When working with Selenium, we utilize an action to interact with an element by clicking on it at specific coordinates (X, Y). action.MoveToElement(element, X, Y).Click().Build().Perform() I am looking to achieve the same functionality using Javascript. ...

Disabling form submission when pressing the enter key

Is there a way to prevent a submit action from occurring when the enter key is pressed within an ASP:TextBox element that triggers an asyncpostback upon text change? Instead, I would like it to click on another button. The Javascript function I am using wo ...

Ways in t4 templates to generate HTML output

I have a complex t4 text template that generates HTML code. This is what the t4 template looks like: <#@ template language="C#" debug="true" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ import namespace= ...

Changing JSON format into a DataTable using C#

Currently, I am attempting to transform a JSON string into a DataTable within WEBAPI The structure of the JSON string is as follows: [ [ "Test123", "TestHub", "TestVersion", "TestMKT", "TestCAP", ... ...

Tips for retaining focus on the same control following an asynchronous postback

I am experiencing an issue with my 3 textboxes, where one is placed in an update panel that refreshes every 4 seconds. Unfortunately, during the refresh process, the focus on controls outside of the update panel is being lost. I need a solution to maintain ...