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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:32:43+00:00 2026-06-13T19:32:43+00:00

I have a main view which has master layout contains all javascripts, ie jQuery

  • 0

I have a main view which has master layout contains all javascripts, ie jQuery DatePicker control, etc.

Inside this main view, I use Ajax.BeginForm(…..) which contains a partial view. And in my controller, if validation fails it returns that partial view. (also the UpdateTargetId in Ajax has been set the Id of the section contains that partial view.)

My error bullets display correctly. However I found I seems to loose the javascript after that. For example my calender/date picker stops working and it comes a normal input box.

What could be the reason?

Thanks a lot!!

Here is the code:

My main view contains one Ajax form. And inside there are 2 partial views. The 2nd one has datepicker inputs.

@using (Ajax.BeginForm("ActionXXX", "ControllerYYY", new AjaxOptions
{
    HttpMethod = "POST",
    UpdateTargetId = "main"        
}))
{
     <section id="main" class="....." data-section="....." data-step="">  

            @Html.Partial("ValidationSummary") 

            @Html.Partial("SharedPartialView", Model, new ViewDataDictionary {.....})          

     </section> 

}

And JS is included in master file. (Main view has Layout for this)

<script type="text/javascript">   

    $('input.date').watermark('dd/mm/yyyy');

    $('input.date').datepicker({
        dateFormat: "dd/mm/yy",
        maxDate: 0, 
        onClose: function () { $(this).valid(); } 
    });    

    $('input.time').watermark('hh:mm');
    $('input.time').timeEntry();

</script>

The controller is just: when validation fails, return partial view (“SharedPartialView”)

if (Request.IsAjaxRequest())
    return PartialView("SharedPartialView", ciShareModel); //model

These datepicker and watermark jquery do work when page initially loaded….

  • 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-13T19:32:44+00:00Added an answer on June 13, 2026 at 7:32 pm

    Are you running the javascript again, after you load the partial view? – A script-block is only run when the page loads, so the in your master page is only run when the master is loaded. When you do an ajax call, you need to run any javascript for the partial view seperately.

    Put this code in your partial view:

    <script type="text/javascript">
        $(document).ready(function() {
            $('input.date').datepicker({
                dateFormat: "dd/mm/yy",
                maxDate: 0, 
                onClose: function () { $(this).valid(); } 
            });
        }); 
    </script>
    

    Although – I suggest instead of using $('input.date'), give your input element a unique ID/class, otherwise you will reset any data a user may have entered in other ‘input.date’ fields on the page. Use for ex: $('input.partialView_Date) and call your input field in the partial view: <input type="text" class="partialView_Date" />

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

Sidebar

Related Questions

I have a main View that has a table which has it's own controller.
I have a MonoTouch iPhone app which has a UITableViewController as it's main view
I have this main.xml layout which has a fixed header and footer. The body
I have a main view to which I have added a subview using the
I have an application composed of a main view and a secondary view which
I have a view which was working fine when I was joining my main
I'm developing an iOS 4 application. I have a main view that contains another
This is my problem, I have the main view which only shows one button,
In the interface designer, I have a very simple setup. The main view (which
I have one single MainViewController which has of course it's one main UIView. I

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.