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