Enhancing functions in C# and JavaScript with additional parameters

Having trouble passing a parameter to a function and adding it to the read function in my script. I added a parameter called val to make the function reusable, but unsure how to integrate it into objhandler.read('one').

Here's what I have in my .js file:

 
var objHandler = new Interact();

function SayRead() {
    try {
        objHandler.Read(function (serverResponse) {
            if (serverResponse.error == null) {   
                var result = serverResponse.result;
                if (result.length > 2) {
                    SessionStore.loadData(Ext.decode(result));
                }
            }
            else {
                alert(serverResponse.error.message);
            }
        }); 
    } catch (e) {
        alert(e.message);
    }
}

SayRead();

In my .ashx.cs file:


public class Interact : JsonRpcHandler
{
    [JsonRpcMethod()]
    public string Read(string val)
    {
        clsDBInteract objDBInteract = new clsDBInteract();
        string result;

        try {
            if (val == "one")
                result = objDBInteract.FetchSessionsJSON();
        } catch (Exception ex) {
            throw ex;
        }

        return result;
    }
}

P.S: Using jayrock library.

Thank you.

Answer №1

Adding additional information would greatly improve the understanding of your situation. It appears that you may be utilizing a framework or tool such as jayrock. Would appreciate clarification.

You should consider testing

objHandler.Read('one', function (serverResponse) {

To my knowledge, this is the method Jayrock typically uses to define functions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The nodemailer module in Node.js encountered an issue while trying to send an email, resulting

Looking to confirm registration, I want to send an email from my server (kimsufi). To accomplish this, I am utilizing nodemailer which can be found at https://github.com/andris9/Nodemailer Encountering the following error: Error occurred Sendmail exited ...

Mastering the Art of Page Scrolling with d3

I would like to implement a scrolling effect for my d3 that allows the entire page to scroll while panning, similar to the effect on challonge (http://challonge.com/tournaments/bracket_generator?ref=OQS06q7I5u). However, I only want the scrolling to occur ...

I am looking to implement a dropdown menu that appears after clicking on an image. Any suggestions on how to achieve this using

I've been experimenting with adding a dropdown class, but I'm feeling a bit lost on where to start. Here's a snippet of code that shows what I'd like to do to add a dropdown menu: <span id="dropdown-info" ng-init= "myVar='i ...

Node.js is having trouble locating the installed MySQL module

I've been attempting to install the mysql module for nodejs using npm on the Windows Subsystem for Linux. After running: sudo npm install -g mysql The console output I received was: + <a href="/cdn-cgi/l/email-protection" class="__cf_email__" da ...

Utilizing VueJS to Establish a Binding Relationship with Props

One of my Vue components is named Avatar.vue, and it is used to create an avatar image based on user-defined props. The parameter imgType determines whether the image should have rounded corners or not. Here is the code: <template> <div> & ...

There is a discrepancy between PHP encryption and asp.net encryption methods

Check out this .NET code snippet public string GetMD5Hash(string name) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] ba = md5.ComputeHash(Encoding.UTF8.GetBytes(name)); StringBuilder hex = new StringBuilder(ba.Length * 2); foreach (b ...

The execution continues even after the application in c# has been closed

I am new to C# and I recently attempted to create a Windows Forms Application (WFA). However, I encountered an issue. When I launch the application, the login form appears first. If I close it without logging in, everything works fine. But, if I log in, th ...

Using Jquery $.ajax may lead to temporary freezing of the Browser

I have a $ajax function that fetches multiple JSON objects from a URL and converts them into divs. There are around 50 objects, and I am using setInterval to call the $ajax function every 10 seconds for updates on each of the created divs. However, I' ...

Managing Custom Boolean strings using Jackson Streaming API

Utilizing the Streaming API provided by Jackson for parsing JSON strings, I have a requirement to recognize "YES" as a boolean type. JsonFactory f = new JsonFactory(); Following that, I proceed with: JsonParser jp = f.createJsonParser(jsonString); Then ...

Here's a method for transferring data from one array to another: when there is existing data in the

Although this may seem simple to some, I have been struggling with it for hours without any success. If I have the following data in an array: var tDataValues = { id: "TenantID", text: "FullName", username: "Username", cnic: 'CNIC&ap ...

Execute unit tests for the nodejs project

Looking to execute the tests for this project on GitHub? Head over to the test folder on https://github.com/node-opcua/node-opcua. However, I'm unsure about the testing framework that was utilized and how to run all the tests. Any guidance would be mu ...

TypeScript combined with Vue 3: Uncaught ReferenceError - variable has not been declared

At the start of my <script>, I define a variable with type any. Later on, within the same script, I reference this variable in one of my methods. Strangely, although my IDE does not raise any complaints, a runtime error occurs in my console: Referenc ...

Transforming ASP.NET MVC Query Results into ViewModels

I have a very straightforward ViewModel called ProductViewModel. public class ProductViewModel { public int ProductID { get; set; } public int CategoryID { get; set; } public string ProductName { get; set; } public string CategoryName { ...

Using Angular to implement floating input labels with typeahead functionality

I recently implemented a style from this source: http://tympanus.net/Development/TextInputEffects/index.html If you want to create an input directive, check out the example on Plunker: https://plnkr.co/edit/wELJGgUUoiykcp402u1G?p=preview While it works p ...

Encountering an issue while attempting to transfer information between screens, receiving the error message: TypeError - undefined is not an object when evaluating 'route.params.item'

Currently facing an issue with my home screen where I am trying to navigate to the reviews screen with title, rating, and body. Previously, everything worked fine using const { item } = route.params;, but now I am encountering a TypeError: undefined is not ...

Tips for choosing the injected HTML's List Element (li) while ensuring it remains concealed

How do I hide the list item with iconsrc="/_layouts/15/images/delitem.gif" image when this div is injected by a first party and I am a third party trying to conceal it? $("<style> what should be inserted here ???? { display: none; } </style>") ...

Multer throws error when trying to upload files as an array instead of individually, displaying an 'Unexpected File Error'

Multer is a key module utilized in conjunction with node js and express for file uploads. On the angular side, I am utilizing the ng-file upload module. When sending multiple files individually, everything works smoothly without any errors. However, when ...

Updating the label on a Highcharts speedometer gauge

I need to customize the number sequence of a speedometer displaying internet bandwidth speed. I have done extensive research but haven't found a solution yet. Below is the code snippet for the highchart gauge. The current label sequence is 0,10,20,30 ...

What are the most appropriate hashing algorithms in .NET for securely hashing passwords?

The importance of securely hashing passwords was highlighted by the password leak incident at LinkedIn. Simply using salt to hash passwords is not secure enough with traditional hashing algorithms like MD5 and SHA, as they are optimized for speed and vulne ...

Customizing Tabs in Material UI v5 - Give your Tabs a unique look

I am attempting to customize the MuiTabs style by targeting the flexContainer element (.MuiTabs-flexContainer). Could someone please clarify the significance of these ".css-heg063" prefixes in front of the selector? I never noticed them before upgrading my ...