Sunday, October 14, 2012

MVC 4 Bundling


Also http://forums.asp.net/t/1776599.aspx/1?MVC+4+0+Bundling+Minification+not+working+


Add to the  View\Web.config :

 
 
   

 

and the following inside View\....cshtml

@if (IsSectionDefined("scripts"))
{
       @RenderSection("scripts", required: false)
}.


Still got errors, so  work around was needed as I had a demo and 2012 release was only in a week....

add    

to



   
    @ViewBag.Title - Movie App
   
   
   
   
   
   
   
   



Master Detail View in MVC4/Razor is easy



///Master


@model MyDataFirst.Master
@{
    ViewBag.Title = "Master";
}


       
           
               
@Model.MasterName

           



//Detail


                    @{ if (Model.Detail != null)
                       {
                           foreach (var item in Model.Detail)
                           {
                       
                           
                                @item.Detail
                           
                       
                           }
                       }
                    }
               


Entity Framework connection string


connectionString="metadata=res:///Model.Project.csdl|res:///Model.Project.ssdl|res://*/Model.Project.msl;

change to

connectionString="metadata=res://*/;

Installing the performance counter strings for service ASP.NET_64 (ASP.NET_64) failed


This is a doozy.  You will not be able to install SharePoint 2010, or change IIS features.  I tried reinstalling frameworks, fiddling in IIS etc.

In the event log you will get
Installing the performance counter strings for service ASP.NET_64 (ASP.NET_64) failed. The first DWORD in the Data section contains the error code.
and
Unable to install counter strings because the SYSTEM\CurrentControlSet\Services\ASP.NET_64\Performance key could not be opened or accessed. The first DWORD in the Data section contains the Win32 error code.

What I did was create a SYSTEM\CurrentControlSet\Services\ASP.NET_64\Performance key (only ASP.NET_64_2.0.50727 exists).
I completely uninstalled IIS and all components, restarted and then redid the IIS I needed to run SharePoint 2010 on my Windows7 machine,

The name ‘InitializeControl’ does not exist in the current context


You may just receive an error like so.
"The name ‘InitializeControl’ does not exist in the current context” – Visual Web Part (Sandboxed) bug and how to fix it

in Visual Studio in a SharePoint Visual Web Part 2012 in a Sandboxed solution.

My error was a "'" as in "'<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>"
instead of "<%@ "

Sorted.

Saturday, October 13, 2012

SharePoint Online viewstate maximum


Big problem, if the viewstate in a SharePoint Online webpart exceed 128KB it breaks with

Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.

Try setting controls to no use viewstate and making viewstate as small as possible.

How to setting values of InfoPath Textbox with jquery/javascript, json.


How to setting values of InfoPath Textbox with jquery/javascript, json.

Put this code in CEWP on a web part page containing an InfoPath Form Web Part.

Set delay, as InfoPath loads asynchronously, so document ready in jquery does not work.

window.onload = function()
{
    window.setTimeout(readyCall, 1000);
}

then get reference

  var textBoxEmployeeId = $("#ctl00_m_g_9053a19d_7ea2_49c3_9af1_11ab9e5bbca3_FormControl0_V1_I1_T2");
 
then call json endpoint

var url = "https://yourserver/endpoint?callback=?";
$.getJSON(url, null, function (data) {
textBoxEmployeeId.val(data["EmployeeNumber"]);
});

then set focus.  This is VERY import in InfoPath, or else it will not presist or preserve the data

textBoxEmployeeId.focus();

In InfoPath set the postback options of the field to NEVER

This way you can call json, or other web services, and write the values to InfoPath

How to hide the "Cannot be Blank" In InfoPath 2010, SharePoint Online


<style type="text/css">

.errorDiv
{
visibility:hidden;
     height:1px;
     overflow-y:hidden;
}
.errorDivClickable
{
visibility:hidden;
     height:1px;
     overflow-y:hidden;
}
</style>

Get all fields for XSLT webpart in SharePoint 2010




Place this in an xslt on the server, then link it in the dataview web part

 

       
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
<xsl:include href="/_layouts/xsl/main.xsl"/>
<xsl:include href="/_layouts/xsl/internal.xsl"/>
<xsl:template match="/">
   <textarea rows="20" cols="100">
       <xsl:apply-templates/>
   </textarea>
</xsl:template>
<xsl:template match="node()|@*">
   <!-- Copy the current node -->
       <xsl:copy>
       <!-- Including any child nodes it has and any attributes -->
       <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
</xsl:template>
</xsl:stylesheet>