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 8172269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:43:49+00:00 2026-06-06T21:43:49+00:00

CustomerController.cs public ActionResult AddCustomer() { return ContextDependentView(new _Customers()); } public ActionResult EditCustomer(int sno) {

  • 0

CustomerController.cs

public ActionResult AddCustomer()
{
    return ContextDependentView(new _Customers());
}

public ActionResult EditCustomer(int sno)
{
    return ContextDependentView(entity.Customers.Where(x => x.sno == sno).FirstOrDefault());
}

private ActionResult ContextDependentView(object model)
{
    string actionName = ControllerContext.RouteData.GetRequiredString("action");
    if (Request.QueryString.AllKeys != null)
    {
        ViewBag.FormAction = "Json" + actionName;
        return PartialView(model);
    }
    else
    {
        ViewBag.FormAction = actionName;
        return View(model);
    }
}

customers.cshtml

@Html.ActionLink("Müşteri Ekle", "AddCustomer", "Customer", routeValues: null, htmlAttributes: new { id = "AddCustomerLink", data_dialog_title = "Yeni Müşteri" })
<div class="div_grid_container" id="div_grid_container_customers">
<table id="table_grid" class="tablesorter">
    <thead>
        <tr>
            <th>
                Güncelle
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@Html.ActionLink("Düzenle", "EditCustomer", "Customer", routeValues: new { sno = item.sno }, htmlAttributes: new { id = "EditCustomerLink", data_dialog_title = "Müşteri Bilgileri Güncelle" })
                </td>
            </tr>
        }
    </tbody>
</table>
</div>

jquery

$(function () {
// Cache for dialogs
var dialogs = {};

var getValidationSummaryErrors = function ($form) {
    // We verify if we created it beforehand
    var errorSummary = $form.find('.validation-summary-errors, .validation-summary-valid');
    if (!errorSummary.length) {
        errorSummary = $('<div class="validation-summary-errors"><span>Lütfen hataları düzeltin ve tekrar deneyin.</span><ul></ul></div>')
            .prependTo($form);
    }

    return errorSummary;
};

var displayErrors = function (form, errors) {
    var errorSummary = getValidationSummaryErrors(form)
        .removeClass('validation-summary-valid')
        .addClass('validation-summary-errors');

    var items = $.map(errors, function (error) {
        return '<li>' + error + '</li>';
    }).join('');

    var ul = errorSummary
        .find('ul')
        .empty()
        .append(items);
};

var resetForm = function ($form) {
    // We reset the form so we make sure unobtrusive errors get cleared out.
    $form[0].reset();

    getValidationSummaryErrors($form)
        .removeClass('validation-summary-errors')
        .addClass('validation-summary-valid')
};

var formSubmitHandler = function (e) {
    var $form = $(this);

    // We check if jQuery.validator exists on the form
    if (!$form.valid || $form.valid()) {
        $.post($form.attr('action'), $form.serializeArray())
            .done(function (json) {
                json = json || {};

                // In case of success, we redirect to the provided URL or the same page.
                if (json.success) {
                    location = json.redirect || location.href;
                } else if (json.errors) {
                    displayErrors($form, json.errors);
                }
            })
            .error(function () {
                displayErrors($form, ['Bilinmeyen bir hata oluştu.']);
            });
    }

    // Prevent the normal behavior since we opened the dialog
    e.preventDefault();
};

var loadAndShowDialog = function (id, link, url) {
    var separator = url.indexOf('?') >= 0 ? '&' : '?';

    // Save an empty jQuery in our cache for now.
    dialogs[id] = $();

    // Load the dialog with the content=1 QueryString in order to get a PartialView
    $.get(url + separator + 'content=1')
        .done(function (content) {
            dialogs[id] = $('<div class="modal-popup">' + content + '</div>')
                .hide() // Hide the dialog for now so we prevent flicker
                .appendTo(document.body)
                .filter('div') // Filter for the div tag only, script tags could surface
                .dialog({ // Create the jQuery UI dialog
                    title: link.data('dialog-title'),
                    modal: true,
                    resizable: true,
                    draggable: true,
                    width: link.data('dialog-width') || 600,
                    beforeClose: function () { resetForm($(this).find('form')); }
                })
                .find('form') // Attach logic on forms
                    .submit(formSubmitHandler)
                .end();
        });
};

// List of link ids to have an ajax dialog
var links = ['#loginLink', '#registerLink', '#AddCustomerLink', '#AddCustomerMeterLink', '#EditCustomerLink'];

$.each(links, function (i, id) {
    $(id).click(function (e) {
        var link = $(this),
            url = link.attr('href');

        if (!dialogs[id]) {
            loadAndShowDialog(id, link, url);
        } else {
            dialogs[id].dialog('open');
        }

        // Prevent the normal behavior since we use a dialog
        e.preventDefault();
    });
});
});

And my question, When I clicked the first link (AddCustomer), it opens a dialog pane. But I clicked other that is in foreach statement, Is does not work(It is opened as classic html not in a dialog-pane). AddCustomer.cshtml and EditCustomer.cshtml are same. When I remove sno from EditCustomer(int sno) action It works.(EditCustomer() instead of EditCustomer(int sno) this work.)

How Can I fix it. I want to pass paramater to action and to use ui-dialog-pane.

Thanks.

  • 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-06T21:43:53+00:00Added an answer on June 6, 2026 at 9:43 pm

    It seems that you use id-selector, i.e. $('#EditCustomerLink')
    Since id should be unique per page, jQuery stops parsing DOM after finding first element with such id.

    That’s why you should use class-selectors. For example:

    <td>@Html.ActionLink("Düzenle", "EditCustomer", "Customer", routeValues: new { sno = item.sno }, htmlAttributes: new { @class = "EditCustomerLink", data_dialog_title = "Müşteri Bilgileri Güncelle" })
    

    And bind click-event to $('.EditCustomerLink')

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

Sidebar

Related Questions

Consider two methods on the controller CustomerController.cs : //URL to be http://mysite/Customer/ public ActionResult
Configuration: component id=customerService service=MyApp.ServiceLayer.ICustomerService`1[[MyApp.DataAccess.Customer, MyApp.DataAccess]], MyApp.ServiceLayer type=MyApp.ServiceLayer.CustomerService, MyApp.ServiceLayer Controller: private ICustomerService _service; public CustomerController()
I have 2 controllers CustomerController and PrivatemessageController Customers has a nonaction method private readonly
So we have our J2EE application using Log4j like this public class CustomerController {
I have the following project layout: MVC UI |...CustomerController (ICustomerRepository - how do I
Quick question. Here is my code: #routes map.resources :customers, :has_many => [:addresses, :matchings] map.connect
I have a check for registration in my RegistrationController: public class RegistrationController : Controller
I have some controllers in my grails application:- LoginController LogoutController SearchableController cirnele.SearchAllController com.ten.cirnelle.domain.CustomerController com.ten.cirnelle.domain.ProjectController
I can display a list of all customers and I can display a list
I'm utterly new to Moq and so far have just follwed the examples outlined

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.