Click here to Skip to main content
15,895,746 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionUnable to send data from view to controller in Asp.Net MVC Pin
harish kashyap0114-Jul-18 8:05
harish kashyap0114-Jul-18 8:05 
AnswerRe: Unable to send data from view to controller in Asp.Net MVC Pin
Bryian Tan14-Jul-18 8:34
professionalBryian Tan14-Jul-18 8:34 
Question.Net Core 2.1 and MVC, playing around with Angular 6 Pin
jkirkerx13-Jul-18 12:21
professionaljkirkerx13-Jul-18 12:21 
AnswerRe: .Net Core 2.1 and MVC, playing around with Angular 6 Pin
Nathan Minier16-Jul-18 1:35
professionalNathan Minier16-Jul-18 1:35 
GeneralRe: .Net Core 2.1 and MVC, playing around with Angular 6 Pin
jkirkerx16-Jul-18 6:43
professionaljkirkerx16-Jul-18 6:43 
AnswerRe: .Net Core 2.1 and Angular 6, styles and fonts Pin
jkirkerx17-Jul-18 12:46
professionaljkirkerx17-Jul-18 12:46 
GeneralRe: .Net Core 2.1 and Angular 6, styles and fonts Pin
jkirkerx17-Jul-18 13:44
professionaljkirkerx17-Jul-18 13:44 
QuestionConditionally Loading Partial View in a Page using Javascript Pin
indian14313-Jul-18 8:10
indian14313-Jul-18 8:10 
Hi,

I am new to MVC want to load 5 different Partial Views on Javascript Conditions, like for example I have a dropdown list, on the page, depending upon the dropdown selection I want to load different Partial View, I am not able to use ViewBag as VieBag value is not changing depending upon the Dropdown list box, it seems I have to do that using jquery or javascript, can anybody please help me in doing it? Even if we can do it by using View is also fine if it is possible, in means if I can achieve it, it would be great. Thanks in advance its little bit urgent, please need your help.
@{
    ViewBag.Title = "ListLookups";
}
<script>
    var UserName = "@ViewBag.UserName";
</script>

<style>
    .k-edit-form-container {
        width: 500px;
    }
</style>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="tab-content" id="dvtabs" style="padding-top:10px;">
        <label class="col-md-4  control-label">Administration for Table: </label>
        @(Html.Kendo().DropDownList().Name("Lookup").OptionLabel("Select")
                      .DataTextField("Text")
                                                     .DataValueField("Value").HtmlAttributes(new { style = "width:280px;", @id = "drpLookup" })
                              .DataSource(dataSource => dataSource.Read(read => read.Action("GetListOfLookupTables", "Admin")))
                              .Events(e =>
                                {
                                    e.Change("GetLookupTableValue");
                                })

<pre>
    )
</div>
<div style="margin-top: 5px; padding-left:3%; padding-right:2%">
    <div>
        <div>
            <h4 id="myHeader"></h4>
        </div>

Here should be my Conditions like (if x==y)
@Html.Partial("_LookupTableNoCode")
else if (x==z)
@Html.Partial("_LookupTableCode")


}


function LookupPopUpTitle(e)
{
var lookupTableName = $("#drpLookup").data("kendoDropDownList").text();

<pre>
if (e.model.isNew())
{
$('.k-window-title').text("Add " + lookupTableName);
e.model.set("CreatedBy", UserName);
//e.model.set("State", "California");
//e.model.set("EffectiveDateFrom", new Date());
}
else
{
$('.k-window-title').text("Edit " + lookupTableName);
e.model.set("ModifiedBy", UserName);
}
}

$(document).ready(function ()
{
//alert("test 1");
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
//alert("test 2");
})

function ConvertLEDate(val)
{
if (val != '' &amp;&amp; val != null &amp;&amp; val != 'undefined')
{
var date = new Date(parseInt(val.substr(6)));
date = date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear();
return date;
}
return null;
}

function DateFormat(val)
{
if (val != '' &amp;&amp; val != null &amp;&amp; val != 'undefined')
{
try
{
var dt = val.getMonth() + 1 + "/" + val.getDate() + "/" + val.getFullYear();
return dt;
}
catch (e)
{
return ConvertLEDate(val);
}
}
return '';
}

function ViewLookupTableValues(e)
{
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var PkContactId = dataItem.Id;
window.location.href = '@Url.Action("GetProgramTypeById", "ProgramType")?id=' + Id + "&amp;Type=View";
}

function GetLookupTableId()
{
return {
LookupTableId: $("#drpLookup").data("kendoDropDownList").value()//, ParentId: PkPrvId, ParentTypeCode: 'PRV'
};
}

function GetLookupTableValue(e)
{
if ($("#drpLookup").data("kendoDropDownList").text() != 'Select')
myHeader.innerText = "List of " + $("#drpLookup").data("kendoDropDownList").text();
else
myHeader.innerText = "";
//myHeader.innerText = "List of " + $("#drpLookup").data("kendoDropDownList").text();
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
}

function GetLookupTableValue1(e)
{
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
}
</pre>





else if its possible with ViewBag is also fine like below, in any means if it is possible, please help me, I need your help friends please.
(if ViewBag.Id==y)
                @Html.Partial("_LookupTableNoCode")
           else if (ViewBag.Id==z)
                @Html.Partial("_LookupTableCode")


Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."
AnswerRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx13-Jul-18 12:13
professionaljkirkerx13-Jul-18 12:13 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14313-Jul-18 13:40
indian14313-Jul-18 13:40 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx16-Jul-18 6:37
professionaljkirkerx16-Jul-18 6:37 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 8:25
indian14318-Jul-18 8:25 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 8:36
professionaljkirkerx18-Jul-18 8:36 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 8:51
indian14318-Jul-18 8:51 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 9:00
professionaljkirkerx18-Jul-18 9:00 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 9:06
indian14318-Jul-18 9:06 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 9:13
professionaljkirkerx18-Jul-18 9:13 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 10:23
indian14318-Jul-18 10:23 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 10:26
professionaljkirkerx18-Jul-18 10:26 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 12:38
indian14318-Jul-18 12:38 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 13:12
professionaljkirkerx18-Jul-18 13:12 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 14:33
indian14318-Jul-18 14:33 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx19-Jul-18 7:09
professionaljkirkerx19-Jul-18 7:09 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14319-Jul-18 7:47
indian14319-Jul-18 7:47 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx19-Jul-18 8:46
professionaljkirkerx19-Jul-18 8:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.