Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9078997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:44:54+00:00 2026-06-16T19:44:54+00:00

I want to take some action on a button click the code is given

  • 0

I want to take some action on a button click
the code is given below—>

<% if(Model!=null && Model.Count>0){%>
<ul>
<% foreach(var Movie in Model)
        {
            %> <li> <%= Movie.Id %>  
            <%= Movie.Title %>  
            <%= Movie.ReleaseDate %> 

            <input type="button" value="edit" name="edit" onclick="EditMovie" /> 
            <input type="button" value="delete" name="delete" /> </li> 
            <% } %>
<% } %>
</ul>

I have some functionality to do, but how to link up these buttons to those controls ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:44:55+00:00Added an answer on June 16, 2026 at 7:44 pm

    You could have a separate form for each button:

    <ul>
        <% foreach(var Movie in Model) { %> 
        <li> 
            <%: Movie.Id %>  
            <%: Movie.Title %>  
            <%: Movie.ReleaseDate %> 
            <%= Html.BeginForm("EditMovie", "Movies", new { id = Movie.Id }, FormMethod.Post) { %>
                <input type="submit" value="edit" name="edit" /> 
            <% } %>
            <%= Html.BeginForm("DeleteMovie", "Movies", new { id = Movie.Id }, FormMethod.Post) { %>
                <input type="submit" value="delete" name="delete" /> 
            <% } %>
        </li> 
        <% } %>
    </ul>
    

    and then you will have 2 respective controller actions:

    [HttpPost]
    public ActionResult EditMovie(int id)
    {
        ...
    }
    
    [HttpPost]
    public ActionResult DeleteMovie(int id)
    {
        ...
    }
    

    As an alternative to using forms you could use AJAX:

    <ul>
        <% foreach(var Movie in Model) { %> 
        <li> 
            <%: Movie.Id %>  
            <%: Movie.Title %>  
            <%: Movie.ReleaseDate %> 
    
            <%= Ajax.ActionLink(
                "edit", 
                "EditMovie", 
                "Movies", 
                new { id = Movie.Id }, 
                new AjaxOptions { HttpMethod = "POST" }
            ) %>
    
            <%= Ajax.ActionLink(
                "delete", 
                "DeleteMovie", 
                "Movies", 
                new { id = Movie.Id }, 
                new AjaxOptions { HttpMethod = "POST" }
            ) %>
        </li> 
        <% } %>
    </ul>
    

    Don’t forget to include the jquery and jquery.unobtrusive-ajax.js scripts to your page if you decide to use Ajax.ActionLink helpers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an HTML link, and I want to take some action when the
I want to find the centroid of each contour.for that i take some sample
i want to add some amounts which in my tuple. i want to take
I want to take backup or restore of my oracle database through .Net code.
I have a button in my webpage with below code - HTML: <button type="submit"
What I'd like to do is take some action using the value returned by
I need a VBA code which can do some action in VBA when the
I need to take some action based on the return value of a background
I want to block a thread until some action completes, but I don't just
I want to take a math expression that takes variables and print (assign to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.