How to put dialog input to Onpost method

I'm trying to make a dialog that lets the user select events to delete with a multiselect and after the user presses accept another dialog will open with a verification question if the user really wants to delete these. If the user accepts I need to send the data from the first dialog to my onpost function. I don't really understand how I can use the dialog with a form method in my razor page because the data does not get send to my onpost function after clicking the accept button.




1 Reply

KP Kokila Poovendran Syncfusion Team November 22, 2023 04:43 PM UTC

Hi Megan Pieters,


Greeting from Syncfusion support!


We understand the importance of seamlessly passing data to the OnPost method in your Razor page. To address your specific scenario, we've prepared a sample that aligns with your needs. Please review the provided code snippet below:


<div id="container" style="height:400px;">

    <ejs-dialog id="dialog" header="Dialog" target="#container" width="250px">

        <e-content-template>

            <form method="post">

                <ejs-multiselect id="games" name="SelectedValues" mode="Box" dataSource="data"></ejs-multiselect>

                <div id="errorMessage">

                    <span asp-validation-for="SelectedValues"></span>

                </div>

                <div id="submitbutton">

                    <button id="submitButton" type="submit" content="Submit" class="btn btn-secondary btn-sm">Submit</button>

                </div>

            </form>

        </e-content-template>

    </ejs-dialog>

</div>

[HomeController.cs]

  [HttpPost]

  public void OnPost()

  {

      SelectedValues = Request.Form["SelectedValues"];  //Triggers form action

      var enteredValue = SelectedValues;

  }




This code snippet captures the selected values from the multiselect in the OnPost method. Please incorporate this solution into your project, and let us know if it meets your requirements.


Attachment: RazorPagesSyncfusion_4dcd420f.zip

Loader.
Up arrow icon