To switch a partial view to the edit view without refreshing the page, you can use AJAX to load the edit view and replace the contents of the partial view with the new content.

Here's an example of how you could implement this using jQuery in your VB.NET ASP.NET view:

  1. Define your HTML markup for the partial view. For example, you might have code like this:
<div id="partial-view">
    @Html.Partial("_PartialView")
</div>

This code creates a div element with an id of partial-view, which will contain the contents of your partial view.

  1. Add a link or button to your main view that will trigger the edit view. For example, you might have code like this:
<a href="#" id="edit-link">Edit</a>

This code creates a link with an id of edit-link, which will trigger the edit view when clicked.

  1. Add a script section to your view where you can define your AJAX behavior. For example, you might have code like this:
<script>
    $(function() {
        $('#edit-link').click(function(e) {
            e.preventDefault(); // prevent the default link behavior
            var url = '@Url.Action("EditAction", "EditController")';
            $.get(url, function(response) {
                $('#partial-view').html(response); // replace the partial view content with the edit view content
            });
        });
    });
</script>

This code attaches a click event handler to the edit link. When the link is clicked, it prevents the default behavior (which would reload the page) and sends an AJAX request to the server using the $.get function. The url variable contains the URL of the edit action method that should be called, and the function(response) code is a callback function that handles the response from the server. In this case, the callback function replaces the contents of the partial-view div with the contents of the edit view.

  1. Define the edit action method in your controller. For example, you might have code like this:
Public Function EditAction() As ActionResult
    Return PartialView("_EditView")
End Function

This action method returns the edit view as a partial view.

In order to have multiple edit forms in a single .NET MVC view written in VB, you can create a partial view for each form that you want to display. Then, in your main view, you can render each partial view within a separate HTML container, such as a

or
element.

Here's an example of how you could implement this in your .NET MVC view:

  1. Create a partial view for each form you want to display. For example, you might create a file called _EditForm1.vbhtml and another file called _EditForm2.vbhtml.

  2. In each of your partial views, define the HTML markup for your form, including any inputs or buttons that you want to display. Make sure to use the appropriate HTML helpers and syntax for creating form elements in VB.NET.

  3. In your main view, use the Html.Partial method to render each of your partial views within a separate HTML container. For example, you might include code like this in your main view:

<div>
    @Html.Partial("_EditForm1")
</div>

<div>
    @Html.Partial("_EditForm2")
</div>

This will render each of your forms within its own

element, allowing you to display multiple forms on the same page. You can also use other HTML containers, such as elements, depending on your specific requirements.

Keep in mind that each form will need its own separate submit button and action method in your controller, so be sure to define those appropriately as well.

To code multiple submit buttons and action methods for multiple forms in a single ASP.NET view written in VB, you can use the Html.BeginForm method to create a form element for each of your forms. You can then specify the action method and controller that should be used when each form is submitted, using the Html.BeginForm method's action and controller parameters.

Here's an example of how you can implement this in your VB.NET ASP.NET view:

  1. Define your HTML markup for each of your forms. For example, you might have code like this:
@Using Html.BeginForm("ActionMethod1", "Controller1")
    ' Form 1 inputs and submit button here
End Using

@Using Html.BeginForm("ActionMethod2", "Controller2")
    ' Form 2 inputs and submit button here
End Using

<div>
    @Html.Partial("_EditForm2")
</div>

This code uses the Html.BeginForm method to create a form element for each of your forms. The action parameter specifies the name of the action method that should be called when the form is submitted, and the controller parameter specifies the name of the controller that contains the action method.

  1. Add a submit button to each form. For example, you might have code like this:
<input type="submit" value="Submit Form 1" />

<input type="submit" value="Submit Form 2" />

Each submit button should be inside its respective form element.

  1. Define the action methods in your controller. For example, you might have code like this:
Public Function ActionMethod1(model As MyModel) As ActionResult
    ' Code to process Form 1 data here
    Return RedirectToAction("Index")
End Function

Public Function ActionMethod2(model As MyOtherModel) As ActionResult
    ' Code to process Form 2 data here
    Return RedirectToAction("Index")
End Function

Each action method should accept a model object that contains the data submitted by the corresponding form. You can then process the data as needed, and return a RedirectToAction result to navigate the user back to your main view (in this case, the "Index" action method).

That's it! With these steps, you should be able to create multiple submit buttons and action methods for multiple forms in a single ASP.NET view written in VB.

To submit the forms without refreshing the main view, you can use AJAX to send the form data to the server and handle the response without reloading the page.

Here's an example of how you could implement this using jQuery in your VB.NET ASP.NET view:

  1. Define your HTML markup for each of your forms. For example, you might have code like this:
@Using Html.BeginForm("ActionMethod1", "Controller1", FormMethod.Post, New With {.id = "form1"})
    ' Form 1 inputs and submit button here
End Using

@Using Html.BeginForm("ActionMethod2", "Controller2", FormMethod.Post, New With {.id = "form2"})
    ' Form 2 inputs and submit button here
End Using

Note that we've added an id attribute to each form element to make it easier to reference in our JavaScript code.

  1. Add a script section to your view where you can define your AJAX behavior. For example, you might have code like this:
<script>
    $(function() {
        $('form').submit(function(e) {
            e.preventDefault(); // prevent the default form submission behavior
            var form = $(this);
            var url = form.attr('action');
            var data = form.serialize(); // serialize the form data
            $.post(url, data, function(response) {
                // handle the response from the server here
            });
        });
    });
</script>

This code attaches a submit event handler to all forms on the page. When a form is submitted, it prevents the default behavior (which would reload the page) and sends an AJAX request to the server using the $.post function. The url variable contains the URL that the form should be submitted to, and the data variable contains the serialized form data. The function(response) code is a callback function that handles the response from the server.

  1. Define the action methods in your controller as before. The difference is that now you'll need to return a response that can be handled by your JavaScript code. For example, you might have code like this:
Public Function ActionMethod1(model As MyModel) As ActionResult
    ' Code to process Form 1 data here
    Return Json(New With {.success = True})
End Function

Public Function ActionMethod2(model As MyOtherModel) As ActionResult
    ' Code to process Form 2 data here
    Return Json(New With {.success = True})
End Function

These action methods return a JSON response that indicates whether the form submission was successful or not.