I wish to display the confirmation message sent from the server-side and then upon the "OK" or "Cancel" event, I intend to run a server-side function

I have a button similar to this example:-

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>  
    <telerik:RadAjaxPanel ID="mainAjaxPanelContentManager" runat="server" Height="100%" LoadingPanelID="contentManagerRadAjaxLoadingPanel" OnAjaxRequest="ContentManagerAjaxRequest"></telerik:RadAjaxPanel>

<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClientClick="test()"/>

then I have a JavaScript function as shown below:-

function test() 
{
    var result;
    var r = confirm("Duplicate Serial Number - Do you want to change it?");
    $find("<%= mainAjaxPanelContentManager.ClientID %>").ajaxRequest(r);    
}

This function successfully triggers the following server-side method:-

protected void ContentManagerAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        if (e.Argument.ToLower() == "true")
        {
        }
    }

However, when I attempt something like this:-

<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClick="btnadd_Click"/>

protected void btnadd_Click(object sender, ImageClickEventArgs e)
    {
        showMessageBox("Hello");
    }

    protected void showMessageBox(string message)
    {
        string sScript = "";
        sScript += "var result;";
        sScript += "var r = confirm('Duplicate Serial Number - Do you want to change it');";       
        sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";


        ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", sScript, true);


    }

The server-side method ContentManagerAjaxRequest is not executed and an exception is thrown stating "Object doesn't support this property or method".

It seems that ajaxRequest() is not supported on the server-side. What would be the alternative solution in this case?

My issue revolves around displaying a confirmation message from the server-side and then triggering a specific server-side method such as "ContentManagerAjaxRequest" based on the user's response.

Answer №1

sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";

Can you explain the purpose of this code?

Wouldn't it make more sense to use something like this (which was done earlier)?

sScript += mainAjaxPanelContentManager.ClientID + ".ajaxRequest(r);";

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

How can I display Yes/No instead of 1/0 in an HTML table?

I am getting a json file from the server with some values 0/1. These values are currently displayed in an HTML table, but I would like them to be displayed as Yes/No instead. How can I achieve this? Here is the code snippet I am using: $.getJSON('li ...

Mistake in labeling a checkboxgroup in ExtJs4.2 by wrapping a boxLabel incorrectly

I am encountering an issue where the box labels of the checkboxes are wrapping under the checkbox: http://jsfiddle.net/6pYWh/ { xtype: 'checkboxgroup', columns: 1, vertical: true, items: [ ...

Issue with Vuex. While this.$store.dispatch(...) is functional, ...mapAction is not working as expected

I am encountering an issue with dispatching Actions from vuex. It's puzzling to me that ...mapActions is not initiating a request to Jsonplaceholder. However, using this.$store.dispatch successfully retrieves all 10 users without any issues. Below are ...

Issues with Angular and Bootstrap: ng-hide functionality not functioning correctly

I am struggling to grasp the concept of the ng-show angular directive as it is not functioning correctly for me. Despite following some examples I found online, I cannot seem to change the boolean value in the controller like they suggest. Instead of using ...

The challenge of accessing controllerAs variables/objects in AngularJS custom directives

After deciding to refactor my code and move DOM manipulation and functions into directives instead of controllers, I encountered an issue with accessing variables/objects defined using the controllerAs 'this' syntax. Despite trying to use bindToC ...

Troubleshoot the Error: EEXIST - Directory already exists at 'C:UsersPhantom' while setting up a React application[RESOLVE]

I'm trying to set up react and start my first project, but I encountered an issue during the installation process. How can I resolve this? Error: EEXIST: file already exists, mkdir 'C:\Users\Phantom' TypeError: Cannot read propert ...

The process of adding new values to an array while maintaining the existing items in the same index position

There are many questions out there about using array push and splice, but none quite like this one. Take a look at this fiddle to see what I've been working on: JS Fiddle This is the output I currently have: [{"rup":"100","dol":"50"},{"rup":"100", ...

Utilizing AngularJS to dynamically bind input to a value with a filter and keep it updated

I'm facing an issue with an input element linked to an object property along with a filter. Even though I update the object.field programmatically, the displayed value in the input does not change, although the correct value is reflected in the DOM In ...

Update the text input field from a different webpage

I am working with two PHP pages, let's call them page1.php and page2.php. On page1.php, there is a textbox with a default value of 0, while on page2.php, there is a button. I have these two pages open in different tabs in a browser. My goal is to have ...

Provide alternative styling through css in instances where the Google Books API does not provide an image

How can I modify the CSS code to display the author and title of a book when there is no image available from the Google Books API? Currently, users see a custom image linked here, but it's not clear what it represents without the name and author inf ...

Can a build definition be created for an ASP.net website, rather than an ASP.net application, using TFS Build?

I'm currently working on an old ASP.net website and I'm trying to set up an automated build using TFS Build. I've encountered numerous issues with this process, whereas building an ASP.net web application is a breeze. Is there a method to s ...

Retrieve the quantity of files in a specific directory by implementing AJAX within a chrome extension

I need assistance with obtaining the count of images in a specific directory using JS and AJAX within my chrome extension. My current code is included below, but it does not seem to be functioning as expected since the alert is not displaying. main.js .. ...

The function get_template_directory_uri() returned an unexpected string error

Exploring WP themes has been an interesting journey for me. Currently, I am working on creating a shortcode for some html/script and encountering an issue with enqueuing the js file. My initial query is about whether I am loading this from the correct loc ...

How can I use Jquery slideToggle() to toggle to a specific height on a

My attempt to create a sliding effect for my div is shown in the code snippet below: $("#toggle").click(function(e) { e.preventDefault(); $("#numbers").slideToggle(); }); Is there a way to limit the slide so that it stops at a certain height, lik ...

Encountering an Issue: The program is throwing a TypeError because it is unable to access properties of null when trying to read '

My goal is to upload an excel file using ng-click and the fileUpload($event) function defined in the app controller scope. I am utilizing xlsx to read the file in JSON format, but I encounter an error when running the code: <div> <input id ...

Generating files using Open XML format

Exploring the WordprocessingDocument class in DocumentFormat.OpenXml.Packaging, I noticed the Create method that takes a string path and a WordProcessingDocumentType as parameters. WordProcessingDocumentType public enum WordprocessingDocumentType { ...

Is there a more efficient method for sequentially processing two separate datatables, each containing 50,000 records, rather than iterating through them

for (var row1 in data1.Rows) { for (var row2 in data2.Rows) { if (row2["Name"].ToString().Equals(row1["CompanyName"].ToString()) && row2["ExecutiveName"].ToString().Equals(row1["ExecutiveName"].ToString())) { ...

The jQuery UI autocomplete feature is showing only the initial entry from the database

When using JQuery Autocomplete in my template, I am encountering an issue where only one item is displayed despite having multiple items fetched in the results. The Autocomplete seems to only show the first item on the list! For example: If my result lis ...

Determine if an HTML element contains a specific class using JavaScript

Is there a simple method to determine if an HTML element possesses a particular class? For instance: var item = document.getElementById('something'); if (item.classList.contains('car')) Remember, an element can have more than one clas ...

Is IPv6 like a JavaScript string in any way?

Introduction In the era of IPv4, life was simpler as IPv4 addresses could easily be converted into 32-bit integers for various calculations. However, with the introduction of IPv6, things have become more complicated due to the lack of native support for ...