I need to add the control in the page at the run time. i have a code to add the control dynamically. but the control disappears when i refresh the page or close the page. i need to display the controls in the page itself when i refresh or close the page.
@using (Html.BeginForm()) {
}
22 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
@Html.ActionLink("Add", "QuestionCreateMatching", "Test", new { id = "addItem" }, null) }
I am getting ,
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'BeginCollectionItem' and no extension method 'BeginCollectionItem' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
have one save button and in controller read the hidden value count and store it in your database. so when next time you load the page read the count from the db and assign to ViewBag.ControlCount
in your cshtml
$(document).ready(function () {
var controlcount =parseInt($("#hdnControlCount").val());
$(document).ready(function() { $("#txt").click(function() { here need to update the count in the database. how to update the value in the db.i m new to jquery
if you maintain in global variable, then once you close your application at that time what should happen. Does it mean you need only when the session is active?
I think we can maintain the count in global variable in the page. According to the count we can create the control. But i did not know how to implement it. it should display in the page load as well as button click event.
Hi, You need to store number of dynamic controls created in your database and when you load next time the same page depend on the count you can create those many number of controls. I believe you are also saving the data for each dynamic control so while creating the control you can also bind the data which was saved earlier.
Iftikar HussainPosted Jul 25, 2013, 8:04 AM
@using (Html.BeginCollectionItem("MatchingQuestionModel"))
{
@Html.LabelFor(m => m.QuestionTitle)
@Html.EditorFor(m => m.QuestionTitle)
}
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 6:50 AM
@using (Html.BeginCollectionItem("MatchingQuestionModel"))
{
@Html.LabelFor(m => m.QuestionTitle)
@Html.EditorFor(m => m.QuestionTitle)
}
@using (Html.BeginForm())
{
@Html.ActionLink("Add", "QuestionCreateMatching", "Test", new { id = "addItem" }, null)
}
I am getting ,
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper
Iftikar HussainPosted Jul 25, 2013, 5:23 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 5:04 AM
Iftikar HussainPosted Jul 25, 2013, 3:21 AM
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 3:15 AM
how do i submit to the page?
Iftikar HussainPosted Jul 25, 2013, 2:57 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 2:48 AM
Iftikar HussainPosted Jul 25, 2013, 2:45 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 2:33 AM
When i click it should add. it should appear when i refresh the page or close the page.
vidhyaPosted Jul 25, 2013, 2:30 AM
Without clicking the save button, i need the controls stable on the page.
Iftikar HussainPosted Jul 25, 2013, 2:08 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 1:59 AM
If i use there(bolded text) it displays at any time. how can i use for loop there.
Iftikar HussainPosted Jul 25, 2013, 1:57 AM
in your cshtml
in your controller
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 1:37 AM
Iftikar HussainPosted Jul 25, 2013, 1:33 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 1:21 AM
Iftikar HussainPosted Jul 25, 2013, 12:59 AM
Regards,
Iftikar
vidhyaPosted Jul 25, 2013, 12:28 AM
$(document).ready(function()
{
$("#txt").click(function()
{
here need to update the count in the database. how to update the value in the db.i m new to jquery
var $ctrl = $('').attr({ type: 'text', name:'text', value:'text'}).addClass("text");
$("#holder").append($ctrl);
});
}
Iftikar HussainPosted Jul 24, 2013, 11:52 PM
Regards,
Iftikar
vidhyaPosted Jul 24, 2013, 11:50 PM
Iftikar HussainPosted Jul 24, 2013, 9:17 AM
You need to store number of dynamic controls created in your database and when you load next time the same page depend on the count you can create those many number of controls. I believe you are also saving the data for each dynamic control so while creating the control you can also bind the data which was saved earlier.
Regards,
Iftikar