Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set the DIV width value using the property list return value in ajax call from control page- MVC2
    primarykey
    data
    text
    <p>I am trying to set the DIV width using the value return from AJAX call from the below code. When i select the check box - the javascript should trigger and sent the ajax req.Aft the ajax code execute i am return the list of property and need to use those value to set the width of the div.</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function () { $(":checkbox").click(function () { var $this = $(this); var checkboxData = $(':checked').val(); $.ajax({ url: '/Home/About', type: 'POST', data: { id: checkboxData }, success: function (result) { //I am not sure that below code is correct but What am trying here to use the returned value to set the DivID and Divwidth $(".#result.data(DivID)").css("width", #result.data(DivWidthList) + "px"); } }); }); }); &lt;/script&gt; &lt;%using (Html.BeginForm()) { %&gt; &lt;%foreach (var cbName in (List&lt;Hello_World_MVC.Option&gt;)ViewData["Data"]) {%&gt; &lt;div id="&lt;%=cbName.OptionID%&gt;" style="background-color:Blue;"&gt; &lt;input type="checkbox" id="myCheckbox" class="&lt;%=cbName.OptionID%&gt;" value="&lt;%=cbName.OptionID%&gt;1" /&gt;&lt;%=cbName.OptionName%&gt; &lt;/div&gt; &lt;%} %&gt; &lt;%} %&gt; </code></pre> <p>Model Page:</p> <pre><code>public class ValueProperty { private List&lt;double&gt; divWidthList = new List&lt;double&gt;(); public List&lt;double&gt; DivWidthList { get; set; } public string DivID { get; set; } } </code></pre> <p>Control page:</p> <pre><code> public ActionResult About(int id) { AboutModels ObjAM = new AboutModels();//model class name ViewData["Data"] = ObjAM.dbValue(); ValueProperty ObjVP = new ValueProperty(); for (int i = 20; i &lt;= 100; i += 20) { ObjVP.DivWidthList.Add(i);//adding the value to property list } foreach (var DivValue in ObjAM.dbValue()) { ObjVP.DivID = Convert.ToString(DivValue.OptionID);//insert the value for DivID } ObjAM.dbUpdate(id); return Json(new { data = ObjVP});//return the property value } </code></pre> <p>I need to use the returned ajax value for set the DivID and DivWidth.Here i have included my Model,Control and View page. Please advice</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload