Partial page are not loading on same page - asp.net-mvc-3

Here is my code has been implemented in a .chtml page. When I click on button corresponding page open in new page instead of same page. I want to open that partial page on same view page. please help me.. Thanks in advance..
<div class="contentbox">
<div class="contentmain">
#using (Ajax.BeginForm("SearchForEdit", "Home", FormMethod.Post, new AjaxOptions { UpdateTargetId = "update_panel", InsertionMode = InsertionMode.Replace }, new { #class = "form-horizontal" }))
{
<ul>
<li><div class="leftc_box" style="width:150px;">Enter Id or Song Name </div>
<div class="rightc_box">
<input type="text" name="entryid" value="" placeholder="Enter Id or Song Name" style="height: 30px;" />
</div>
</li>
<li>
<div class="leftc_box" style="margin-left:153px;"><input type="image" name="" src="../../Content/img/submit.png" value="" /></div>
</li>
</ul>
<div id="update_panel">#Html.Partial("SearchForEdit")</div>
}
<div>
<table style="border-style: solid; border-width: thin; height: auto; width: 100%; margin-top: 8px;">
<tr style="background: #f4f4f4;">
<th align="center">ID</th>
<th align="center">Song Name</th>
<th align="center">Album Name</th>
<th align="center">Label Name</th>
</tr>
#foreach (xxxxxxxxxxx ienctry in obmain)
{
<tr class="divset">
<td align="center">#ienctry.id</td>
<td align="center">#ienctry.Song</td>
<td align="center">#ienctry.Album</td>
<td align="center">#ienctry.Label</td>
</tr>
}
</table>
</div>
</div>
</div>
and my controller is this..
[HttpPost]
public ActionResult SearchForEdit(int entryid)
{
ViewBag.searchid = entryid;
return PartialView("SearchForEdit");
}
Here is my partial page...
#{
int ssid = 0;
if(ViewBag.searchid!=null)
{
ssid = ViewBag.searchid;
}
List<XXXXXXXX> mainobject = XXXXXXXXXXXXXXXXX.Service.Class1.SearchnUpdate(ssid);
ViewBag.Title = "title";
}
<div>
<table style="border-style: solid; border-width: thin; height: auto; width: 100%; margin-top: 8px;">
#if (mainobject.Count > 0)
{
<tr style="background: #f4f4f4;">
<th align="center">ID</th>
<th align="center">Song Name</th>
<th align="center">Album Name</th>
<th align="center">Label Name</th>
<th align="center"></th>
</tr>
foreach (XXXXXXXXXX ientry in mainobject)
{
<tr style="background: #f4f4f4;">
<td align="center">#ientry.id</td>
<td align="center">#ientry.Song</td>
<td align="center">#ientry.Album</td>
<td align="center">#ientry.Label</td>
<td align="right"><img src="../../Content/img/update.png"</td>
</tr>
}
}
</table>
</div>
Here is my method has been defined in class1 page..
public static List<xxxx> SearchnUpdate(int searchid)
{
string ssongname=searchid.ToString();
List<xxxx> obj = new List<xxxx>();
using (xxxxxxxxx dbcontext = new xxxxxxxxxx())
{
obj = (from z in dbcontext.xxxxx where z.id == searchid || z.Song == ssongname select z).ToList();
}
return obj;
}

Related

how to add client confirmation on delete record in asp.net core 1.0

i am use asp.net core 1.0 and in this i want to add client confirmation on delete record
my code belowe
#model IEnumerable<Login.Model.UserAccount>
#{
ViewData["Title"] = "Home Page";
}
<div class="row">
<div class="col-md-12">
<h2>Registered user</h2>
#if (Model.Any())
{
<table class="table">
<tr>
<th>First name</th>
<th>Last Name</th>
<th>EmaiID</th>
<th>Use Name</th>
<th></th>
</tr>
#foreach (var item in Model)
{
<tr>
<td>#item.FirstName</td>
<td>#item.LastName</td>
<td>#item.Email</td>
<td>#item.UserName</td>
<td>
<a asp-action="Edit" asp-route-id="#item.UserID">Edit</a> |
<a asp-action="Delete" asp-route-id="#item.UserID">Delete</a>
</td>
</tr>
}
</table>
}
else
{
<p> There is no registered users.</p>
}
</div>
</div>
in above code delete operation perform successfully but i want to add add client confirmation before delete, if action ok than delete and if action cancle than not delete.
function ConfirmDelete()
{
var x = confirm("Are you sure you want to delete?");
return X;
}
<input type="button" Onclick="ConfirmDelete()">

Kendo Window won't load data from model

#model Example.Model1ViewModel
#if (Model != null && Model.TableSix != null)
{
<table>
<thead>
<tr>
<td style="width:60%"></td>
<td style="width:20%">Outstanding Amount</td>
</tr>
</thead>
<tbody>
<tr>
<td>Total</td>
<td class="Total cursor">#Html.DisplayFor(x => x.TableSix.Total)</td>
</tr>
<tr>
<td>One</td>
<td>#Html.DisplayFor(x => x.TableSix.One)</td>
</tr>
<tr>
<td>Two</td>
<td>#Html.DisplayFor(x => x.TableSix.Two)</td>
</tr>
</tbody>
</table>
}
<div style="display: none">
#(Html.Kendo().Window()
.Name("RemainingAssetsDrillDown")
.Modal(true)
.Title("Item Drill Down")
.Actions(actions => actions.Close())
.Content(#<text>
<div>
<table>
<tbody>
<tr>
<td>One</td>
<td>#Html.DisplayFor(x => x.TableSix.One)</td>
</tr>
</tbody>
</table>
</div>
</text>)
</div>
)
$(".Total").click(function () {
$("#MVC").load('#Url.Action("PartList", "Report")');
var win = $("#DrillDown").data("kendoWindow");
win.center().open();
});
<style type="text/css">
.cursor {
cursor: pointer;
}
</style>
So, the problem is that #Html.DisplayFor(x => x.TableSix.One) fetches the correct value from the view model in the first table, but in the table under kendo window I get the value as 0.
Any idea how I can get #Html.DisplayFor(x => x.TableSix.One) to display the value from the view model into the table that is under kendo window?
Thanks in advance. :)

MVC3 IPagedList in ViewModel

I want to have a page that has a form on the top of the page to enter movies in a system, and on the bottom of the page I want to have a table to display all of the movies in inventory. I am getting an error saying: Value cannot be less than 1. Parameter name: Page Size.
I have a viewmodel that currently looks like this:
public class InventoryViewModel
{
public Inventory Inventory { get; set; }
public IPagedList<Inventory> InventoryList { get; set; }
}
In my controller I have:
public ActionResult Index(int? page)
{
ViewBag.MoviesList = new SelectList(inventoryRepository.Movies, "MovieId", "Title");
InventoryViewModel vm = new InventoryViewModel
{
Inventory = new Inventory(),
InventoryList = inventoryRepository.GetInventory.ToPagedList(page.HasValue ? page.Value - 1 : 0, defaultPageSize)
};
return View(vm);
}
In my view I have:
<div class="well">
<h4>Enter Movie in System:</h4>
#using (Html.BeginForm()) {
#Html.ValidationSummary(true, "Movie was not entered in system. Please correct the errors and try again.")
<div>
<div class="input-prepend">
<span class="add-on"><i class="icon-film"></i></span>
#Html.DropDownListFor(m => m.Inventory.MoviesId, (SelectList)ViewBag.MoviesList)
#Html.ValidationMessageFor(m => m.Inventory)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-calendar"></i></span>
#Html.TextBox("Quantity")
</div>
<p><button class="btn btn-primary" type="submit" value="Submit">Submit</button></p>
#Html.ValidationSummary()
</div>
}
</div>
<div>
<h3>Current Inventory:</h3>
</div>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th style="width: 15%;">Checkout Number</th>
<th style="width: 15%;">Title</th>
<th style="width: 23%;">Availability</th>
<th style="width: 17%;"></th>
</tr>
</thead>
<tbody>
#foreach (var vm in Model.InventoryList.OrderBy(m => m.CheckoutNum))
{
<tr>
<td>#vm.CheckoutNum</td>
<td>#vm.Movies.Title</td>
<td>#vm.isAvail</td>
<td>
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="4">
#Html.Pager(Model.InventoryList.PageSize, Model.InventoryList.PageNumber, Model.InventoryList.TotalItemCount).Options(o => o
.DisplayTemplate("BootstrapPagination").RouteValues(new { q = ViewBag.Query, area = "" } )
.AlwaysAddFirstPageNumber().MaxNrOfPages(5))
</td>
</tr>
</tfoot>
</table>
I figured it out. I was setting the defaultPageSize in the wrong constructor, so the variable was never getting set, causing the page size to be 0.
int defaultPageSize;
private IInventoryRepository inventoryRepository;
public InventoryController()
{
this.inventoryRepository = new InventoryRepository(new MovieContext());
this.defaultPageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["defaultPageSize"]);
}
public InventoryController(IInventoryRepository inventoryRepository)
{
this.inventoryRepository = inventoryRepository;
this.defaultPageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["defaultPageSize"]);
}

Object doesn't support property or method 'dataTable'

Hi I am trying to implement a data table in Visualforce page. I have included the jquery.js, DataTable.Min.Js, Datatable.js in the page in this order. I have initialize the data table like below
$(document).ready( function () {
var oTable1 = $('#LeadTable').dataTable( {
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
"bLengthChange": false,
"bAutoWidth": false,
"iDisplayLength" : 20,
"aaSorting": [[ 4, "desc" ]],
"oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ] }
});
});
I am getting the error "Object doesn't support property or method 'dataTable'". I check what is the issue?
Thanks.
VF page
<apex:page controller="HomeBasedClass" id="thePage" >
<apex:stylesheet value="{!$Resource.RoleHierarchyPopupStyle}"/>
<style type="text/css">
body{
background-color: #f5f5f5;
}
#Initialloading{
width: 100%;
height: 500px;
top: 200px;
/*left: 200px;*/
/*position: fixed;*/
display: block;
z-index: 99
}
#loading-image{
position: absolute;
top: 40%;
left: 45%;
z-index: 100
}
</style>
<script type="text/javascript">
var i = setInterval(function () {
clearInterval(i);
// The desired code is only this:
document.getElementById("Initialloading").style.display = "none";
document.getElementById("thePage:formId").style.display = "";
}, 5000);
</script>
<script type="text/javascript">
function showPopUp(divId)
{
document.getElementById(divId).style.display = '';
}
function ClosePopup(divId){
document.getElementById(divId).style.display = 'none';
}
</script>
<style>
#LeadTable { border-collapse: collapse; }
h3 { color: #333333;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 20px;
}
#panel table { border-collapse: collapse; }
</style>
<style>
.button { background: url('{!$Resource.LoadingButton}') no-repeat left top; width:335px; height:65px;}
.circle {
width:22px;
height:22px;
float:left;
margin-bottom:18px;
margin-top:18px;
margin-left: 55px;
}
.txt {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:13px;
color:#000000;
line-height:20px;
margin-left:15px;
margin-bottom:18px;
margin-top:18px;
width: 200px;
font-weight: bold;
float: left;
}
#TaskTable_paginate {
height:35px;
}
</style>
<div id="Initialloading" align="center">
<img src="{!$Resource.Loading}" />
<br/><br/>
<font color="Red">Please Wait...</font>
</div>
<apex:form id="formId" style="display:none;">
<!--<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>-->
<!--<apex:includeScript value="{!$Resource.jQueryLib19Compress}"/>
<script src="{!URLFOR($Resource.DataTables, 'media/js/jquery.dataTables.min.js')}"></script>
<script src="{!URLFOR($Resource.DataTables, 'media/js/jquery.dataTables.js')}"></script>
<script src="{!URLFOR($Resource.DataTables, 'media/js/ColVis.js')}"></script>
<script src="{!URLFOR($Resource.DataTables, 'media/js/ZeroClipboard.js')}"></script>
<script src="{!URLFOR($Resource.DataTables, 'media/js/TableTools.js')}"></script>
<script src="{!URLFOR($Resource.DataTables, 'media/js/ColumnFilterWidgets.js')}"></script>-->
<apex:includeScript value="{!$Resource.DtJQueryJs}"/>
<apex:includeScript value="{!$Resource.DtDataTableMinJs}"/>
<apex:includeScript value="{!$Resource.DtDataTableJs}"/>
<apex:stylesheet value="{!URLFOR($Resource.DataTables, 'media/css/DataTablesAdvancedExample.css')}"/>
<script type="text/javascript">
$(document).ready( function () {
var oTable1 = $('#LeadTable').dataTable( {
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
"bLengthChange": false,
"bAutoWidth": false,
"iDisplayLength" : 20,
"aaSorting": [[ 4, "desc" ]],
"oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ] }
});
var oTable2 = $('#JobprofileTable').dataTable( {
"sPaginationType": "full_numbers",
"iDisplayLength" : 5,
"bLengthChange": false,
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
"aaSorting": [[ 5, "desc" ]],
"oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ]}
});
});
function startSplash() {
document.getElementById('splashDiv').style.display='';
}
function endSplash() {
document.getElementById('splashDiv').style.display='none';
}
</script>
<div class="button" id="splashDiv" style="display: none; position: fixed; left: 500px; top: 250px; border: 0px; z-index: 9999;">
<div class="circle"><apex:image value="{!$Resource.LoadingImage}"></apex:image></div>
<div class="txt">Please Wait. Loading...</div>
</div>
<apex:actionStatus id="splashStatus" onstart="startSplash();" onstop="endSplash();" />
<apex:actionFunction name="ajaxSetClientLoaded" action="{!setClientLoaded}" immediate="true" rerender="formId"/>
<apex:sectionHeader subtitle="Home Base - Sales Rep Dashboard"/>
Leads |<apex:outputLabel > </apex:outputLabel><apex:outputLabel >Job Profiles</apex:outputLabel><apex:outputLabel > |</apex:outputLabel> Opportunities | Activities | Orders & Deliveries<br/><br/><br/>
<label style="cursor:pointer; text-decoration:underline" onclick="showPopUp('descreteAddDiv');">{!$UserRole.Name}</label><br/><br/>
<div id="descreteAddDiv" style="display:none;">
<apex:outputPanel styleClass="DescAddresspopupBackground" layout="block" />
<apex:outputPanel id="fulfillingBranchPanel" style="-moz-border-radius: 15px;-webkit-border-radius: 15px;border-radius: 10px;" styleClass="custDescAddressPopup" layout="block" >
<div style="width:25px; float:right;padding:5px 5px; cursor:pointer;" onclick="ClosePopup('descreteAddDiv');">[X]</div>
<apex:iframe src="/apex/testpage" width="100%" height="350px" scrolling="true"/>
</apex:outputPanel>
</div>
<!-- ----------------------------------------------------Lead section Start------------------------------------------ -->
<apex:pageBlock id="leadSection" >
<table width="100%" border="1" cellpadding="5" cellspacing="8">
<tr>
<td align="left" colspan="2"><h3>Leads</h3></td>
</tr>
<tr>
<td width="25%" valign="top" height="265px;">
<apex:outputPanel id="componentPnl">
<c:LeadGraphComponent userId="{!SelectedUserId}" id="LeadComponent"/>
</apex:outputPanel>
</td>
<td width="75%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="LeadTable" >
<thead>
<tr>
<th style="font-weight: bold; text-align: center; font-family: Arial; font-size: 8pt;">Company</th>
<th>Name</th>
<th>Phone</th>
<th>Servicing Branch ID</th>
<th>Created Date</th>
<th>Last Activity Date</th>
<th>Next Activity Date</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!LstLeadGrid}" var="c">
<tr>
<td>{!c.Company}</td>
<td>{!c.Name}</td>
<td>{!c.Phone}</td>
<td>{!c.Servicing_Branch_Id__c}</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Created_Date_Time__c}"/>
</apex:outputText>
</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Last_Activity_Datetime__c }" />
</apex:outputText>
</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Next_Activity_Date__c}" />
</apex:outputText>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
</td>
</tr>
</table>
</apex:pageBlock>
<!-- ----------------------------------------------------Lead section End------------------------------------------ -->
<!-- ----------------------------------------------------Job Profile section Start------------------------------------>
<!-- ------rendered="{!IF(($UserRole.Name == 'Branch Manager - US') || ($UserRole.Name == 'Customer Sales Specialist - NSC - US') || ($UserRole.Name == 'Regional Manager - US') || ($UserRole.Name == 'Sales Rep - US') || ($UserRole.Name == 'Territory Sales Mgr - US'),true,false)}"---->
<apex:pageBlock id="jobProfileSection" >
<table width="100%" border="1" cellpadding="5" cellspacing="8">
<tr>
<td align="left" colspan="2"><h3>Job Profiles</h3></td>
</tr>
<tr>
<td width="25%" valign="top" height="265px;">
<apex:outputPanel id="componentPnl">
<c:JobProfileComponent userId="{!SelectedUserId}" id="JpComponent"/>
</apex:outputPanel>
</td>
<td rowspan="2" width="75%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="JobprofileTable" >
<thead>
<tr>
<th>Job profile Name</th>
<th>Job Profile ID</th>
<th>BranchID</th>
<th>Valuation</th>
<th>GC Name</th>
<th>JS City</th>
<th>JS State</th>
<th>Job Name</th>
<th>JS Zip</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!LstJobProfileGrid}" var="c">
<tr>
<td align="left" style="font-colour: black;">{!c.Name}</td>
<td align="center">{!c.Job_Profile_ID__c}</td>
<td align="center">{!c.Branch_ID__c}</td>
<td align="center">{!c.Valuation__c}</td>
<td align="center">{!c.GC_Awarded_Dodge__c}</td>
<td align="center">{!c.Job_Site_City__c}</td>
<td align="center">{!c.Job_Site_State__c}</td>
<td align="center">{!c.Name}</td>
<td align="center">{!c.Job_Site_Zip__c}</td>
</tr>
</apex:repeat>
</tbody>
</table>
</td>
</tr>
</table>
</apex:pageBlock>
<!-- ----------------------------------------------------Job Profile End------------------------------------------ -->
<!-- ----------------------------------------------------Opportunity section Start------------------------------------------ -->
<apex:pageBlock id="OpportunitySection">
<c:OpportunityComponent userId="{!SelectedUserId}" id="OppComponent"/>
</apex:pageBlock>
<!-- ----------------------------------------------------Opportunity section End------------------------------------------ -->
<!-- ----------------------------------------------------Activity section Starts------------------------------------------ -->
<apex:pageBlock id="TaskSection">
<script type="text/javascript" charset="UTF-8">
$(document).ready( function () {
var oTable4 = $('#TaskTable').dataTable( {
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
"bLengthChange": false,
"iDisplayLength" : 20,
"oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ] }
});
});
</script>
<table width="100%" border="0">
<tr>
<td align="left">
<h3>My Activities</h3> <a target="_blank" href="https://cs3.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Opportunity&retURL=%2F006%2Fo&save_new_url=%2F006%2Fe%3FretURL%3D%252F006%252Fo" style="Text-decoration:none;Cursor:pointer"><img src="https://cs3.salesforce.com/resource/1359464023000/ZoomImage" Title="Create New Opportunity"/> Create New Opportunity</a>
</td>
<td align="right">
<apex:selectList value="{!SelectedTaskName}" size="1" style="width:250px;">
<apex:selectOptions value="{!lstTaskOptions}"/>
<apex:actionSupport event="onchange" action="{!ChangeSelectedTaskName}" rerender="TaskSection" status="splashStatus"/>
</apex:selectList>
</td>
</tr>
</table>
<div id="panel" >
<table cellpadding="0" cellspacing="0" border="0" class="display" id="TaskTable" style="margin-top:20px;">
<thead>
<tr>
<th>Subject</th>
<th>Due Date</th>
<th>MMI Call Type</th>
<th>Account Name</th>
<th>Name</th>
<th>Related To</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!LstTaskGrid}" var="c">
<tr>
<td>{!c.Subject}</td>
<td style= "{!IF(AND(NOT(ISBLANK(c.ActivityDate)),c.ActivityDate- Today() < 0), 'color:red;', 'color:black;')}">
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.ActivityDate}" />
</apex:outputText>
</td>
<td>{!c.Call_Type__c}</td>
<td>{!c.Account.Name}</td>
<td>{!c.Who.Name}</td>
<td>{!c.What.Name}</td>
<td>{!c.Who.Phone}</td>
</tr>
</apex:repeat>
</tbody>
</table>
</div>
</apex:pageBlock>
<!-- ----------------------------------------------------Activity section End------------------------------------------ -->
<!-- ----------------------------------------------------Order and Delivery section Starts------------------------------------------ -->
<div style="width:100%; overflow:auto;border: 1px solid #F00;" >
<apex:pageBlock id="OrderSection">
<script type="text/javascript" charset="UTF-8">
$(document).ready( function () {
var oTable5 = $('#OrderTable').dataTable( {
"sPaginationType": "full_numbers",
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
"bLengthChange": false,
"bAutoWidth": false,
"iDisplayLength" : 15,
"oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ] }
});
});
</script>
<table width="100%" border="0">
<tr>
<td align="left">
<h3>Orders & Deliveries</h3>
</td>
<td align="right">
<apex:selectList value="{!SelectedlstOrdDelivOptionsName}" size="1" style="width:250px;">
<apex:selectOptions value="{!lstOrdDelivOptions}"/>
<apex:actionSupport event="onchange" action="{!ChangeOrderDelivery}" rerender="OrderSection" status="splashStatus"/>
</apex:selectList><br/><br/>
<apex:selectList value="{!SelectedOrdDelivTimeName}" size="1" style="width:250px;">
<apex:selectOptions value="{!lstOrdDelivTimeOptions}"/>
<apex:actionSupport event="onchange" action="{!ChangeOrderDelivery}" rerender="OrderSection" status="splashStatus"/>
</apex:selectList>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="OrderTable" style="margin-top:20px;">
<thead>
<tr>
<th>Account #</th>
<th>Account Name</th>
<th>Order Type</th>
<th>Transaction Code</th>
<th>Servicing Branch ID</th>
<th>Item Code</th>
<th>Total Amt</th>
<th>Delivery Date</th>
<th>Activation Date</th>
<th>Fuel Surcharge Delivery</th>
<th>Fuel Surcharage PickUp</th>
<th>PPE</th>
<th>LLW</th>
<th>Delivery Contact Name</th>
<th>Delivery Contact #</th>
<th>Order #</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!LstOrdersAndDelieveriesGrid}" var="c">
<tr>
<td>{!c.Account_Number__c}</td>
<td>{!c.Name}</td>
<td>{!c.Transaction_Code__c}</td>
<td>{!c.Transaction_Code__c }</td>
<td>{!c.Transaction_Code__c}</td>
<td>{!c.Item_Code__c}</td>
<td>{!SUBSTITUTE(TEXT(ROUND(c.Total__c, 0)), ".", "," )}</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Delivery_Date__c}"/>
</apex:outputText>
</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Activation_Date__c}"/>
</apex:outputText>
</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Fuel_Surcharge_Delivery__c}"/>
</apex:outputText>
</td>
<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!c.Fuel_Surcharage_PickUp__c}"/>
</apex:outputText>
</td>
<td>{!c.PPE__c}</td>
<td>{!c.LLW__c}</td>
<td>{!c.Delivery_Contact_Name__c}</td>
<td>{!c.Delivery_Contact_Number__c}</td>
<td>{!c.Order_Number__c}</td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:pageBlock>
</div>
<!-- ----------------------------------------------------Order and Delivery section End------------------------------------------ -->
</apex:form>
<style>
body{
background-color: #f5f5f5;
}
/*#OrderTable_wrapper {width:100%; overflow:auto;}*/
</style>
</apex:page>
seems that you should to use the following fix:
var j$ = jQuery.noConflict();
The problem is that force.com also includes a lot of javascript libraries that also may use this $ symbol as a shortcut and this can cause all sorts of problems.
Now where ever you would normally use $, use j$.

MVC3 ASP Replace null value with empty space on the view

I have the following view which returns some text if the POnumber is null.
What I think I need to have instead of the if(Model.Invoice.PONumber == null) is a check mechanism ( maybe multiple if statements ) that will check the fields LineNumber, Description, UnitOfMeasure, QtyOrdered and if any of them is null it will replace it with N/A or empty space but it will still allow the user to see the rest of information available.
Do you have any sugestions? I am new to MVC and any help will be apreciated.
Thank you in advance for your time and help,Bobby
<div class="contentWrapper2">
<div class="content2">
<div class="clr lfl w100">
<h1>Invoice Detail</h1>
<div class="return-btn">
<a class="btn btnStyleC btn-back-invoice" href="#Url.Action("InvoiceHistory", "Account")">
Back to Invoice List</a>
</div>
</div>
#if (Model.ErpError.Length > 0)
{
<div class="clr lfl w100 error">
#Html.Raw(Model.ErpError)
</div>
}
else
{
if(Model.Invoice.PONumber == null)
{
<div class="lfl w100 clr messaging">
<p>No information available at the moment for current invoice.
Please call our sales department for further assistance.
</p>
</div>
}
else
{
<div class="clr lfl w100">
<div class="order-number-date">
<table>
<tr>
<th class="col-1">
<h3>Invoice #:</h3>
</th>
<td class="col-2">
<h3>#Model.Invoice.InvoiceNumber</h3>
</td>
</tr>
<tr>
<th class="col-1">
<h3>Invoice Date:</h3>
</th>
<td class="col-2">
<h3>#Model.Invoice.InvoiceDate.ToShortDateString()</h3>
</td>
</tr>
</table>
</div>
<div class="order-number-date">
<table>
<tr>
<th class="col-1">
<h3>Order #:</h3>
</th>
<td class="col-2">
<h3>#Model.Invoice.OrderNumber</h3>
</td>
</tr>
<tr>
<th class="col-1">
<h3>PO #:</h3>
</th>
<td class="col-2">
<h3>#Model.Invoice.PONumber</h3>
</td>
</tr>
<tr>
<th class="col-1">
<h3>Due Date:</h3>
</th>
<td class="col-2">
<h3>#Model.Invoice.DueDate.ToShortDateString()</h3>
</td>
</tr>
</table>
</div>
</div>
<div class="clr lfl w100">
<div class="bill-ship">
<table>
<tr>
<th>
<h4>Billing Information</h4>
</th>
</tr>
<tr>
<td>#Model.Invoice.BTDisplayName
</td>
</tr>
<tr>
<td>
<#Html.Raw(Model.Invoice.BTAddress1)
</td>
</tr>
#if (!string.IsNullOrEmpty(Model.Invoice.BTAddress2))
{
<tr>
<td>#Html.Raw(Model.Invoice.BTAddress2)
</td>
</tr>
}
<tr>
<td>#Html.CityCommaStateZip(Model.Invoice.BTCity, Model.Invoice.BTState, Model.Invoice.BTZip)</td>
</tr>
<tr>
<td>#Model.Invoice.BTCountry
</td>
</tr>
<tr>
<td>#Model.Invoice.BTPhone1</td>
</tr>
<tr>
<td>#Model.Invoice.BTEmail
</td>
</tr>
</table>
</div>
</div>
if (Model.Invoice.InvoiceLines.Count > 0)
{
<div class="clr lfl w100 line-item-detail">
<table class="info-tbl">
<tr>
<th class="vid-item">Item #</th>
<th class="vid-desc">Description</th>
<th class="vid-um">
U/M
</th>
<th class="vid-qty">
Qty
</th>
<th class="vid-ship">
Ship Date
</th>
#if (Model.ShowPackslip)
{
<th class="vid-pack">Pack Slip</th>
}
<th class="vid-unit">Unit Price</th>
<th class="vid-ext">Ext Price</th>
</tr>
#foreach (var invoiceLine in Model.Invoice.InvoiceLines)
{
<tr>
<td class="vid-line">#invoiceLine.LineNumber</td>
<td class="vid-desc">#invoiceLine.Description</td>
<td class="vid-um">#invoiceLine.UnitOfMeasure</td>
<td class="vid-qty">#invoiceLine.QtyOrdered</td>
<td class="vid-ship">
#if (invoiceLine.ShipDate.ToShortDateString() == "1/1/0001")
{
}
else
{
#invoiceLine.ShipDate.ToShortDateString()
}
</td>
#if (Model.ShowPackslip)
{
<td class="vid-pack">
#invoiceLine.PackSlip
</td>
}
<td class="vid-unit">#invoiceLine.UnitPrice.ToCurrency()
</td>
<td class="vid-ext">#invoiceLine.ExtendedPrice.ToCurrency()
</td>
</tr>
}
</table>
</div>
}
<div class="clr lfl w100">
<table class="tbl-total">
<tr class="subtotal">
<th class="col-1">Subtotal</th>
<td class="col-2">#Model.Invoice.OrderSubTotal.ToCurrency()
</td>
</tr>
#if (Model.Invoice.DollarOffOrder > 0)
{
<tr>
<th class="col-1">Order Discount</th>
<td class="col-2">#Model.Invoice.DollarOffOrder.ToCurrency()</td>
</tr>
}
#if (Model.Invoice.ShippingAndHandling > 0)
{
<tr>
<th class="col-1">Shipping</th>
<td class="col-2">#Model.Invoice.ShippingAndHandling.ToCurrency()
</td>
</tr>
}
#if (Model.Invoice.MiscCharges > 0)
{
<tr>
<th class="col-1">Misc. Charges</th>
<td class="col-2">#Model.Invoice.MiscCharges.ToCurrency()</td>
</tr>
}
<tr>
<th class="col-1">Sales Tax</th>
<td class="col-2">#Model.Invoice.TotalTax.ToCurrency()</td>
</tr>
<tr>
<th class="col-1">Invoice Total</th>
<td class="col-2">#Model.Invoice.InvoiceTotal.ToCurrency()</td>
</tr>
</table>
</div>
<div class="clr lfl w100">
<a class="btn btnStyleB btn-print" href="javascript:window.print();">Print</a>
</div>
}
}
</div>
</div>
You could create a template called for example "nullcheck.cshtml" like:
#if (ViewBag.ValueToCheck == null) {
<div class="lfl w100 clr messaging">
<p>
No information available at the moment for #(ViewBag.Field).
Please call our sales department for further assistance.
</p>
</div>
}
else {
#Html.Partial(ViewBag.TargetTemplate, Model)
}
Then you call it from your main view:
#{
ViewBag.TargetTemplate = "okModel";
ViewBag.Field = "P.O.Number";
ViewBag.ValueToCheck = Model.Invoice.PONumber;
Html.RenderPartial("nullCheck", Model, ViewBag);
}
okModel.cshtml should be the part of your template you will display when the value is not null...
I haven't tested this myself but it should give you some ideas... contact me if things go wrong XD
Cheers!
This seems like something you should take care of in your controller.
public ActionResult YourControllerAction()
{
var myViewModel = SomeService.GetMyViewModel();
if (myViewModel.Invoice.PONumber == null)
{
myViewModel.Invoice.PONumber = "N/A";
}
//etc
}
This leaves your view clearer (my personal preference)
However in the view you could simply use the null coalescing operator like so:
#Model.Invoice.PONumber ?? "NA"

Resources