JavaScript executed from Ribbon on GridView

I had to fix the following.
Disable the Activate button on subentity records based on some value of the parent record.

The disabling should be done on the Edit-form… but in the subgrid as well.
The absense of the webresources on the subgrid was the challenge.
Here’s how:

function EnableActivateButton() {
   if (quoteid === "" && contractid === "") { return false; } 

   try {
      var varMyValue = Xrm.Page.getAttribute("CRMFieldSchemaName").getValue(); 
   catch (e) {
      var entity =; 
      var recordid =; 
      if (recordid === "") { return false; }

Localized ASP.NET RangeValidator with correct DateFormat

I needed a RangeValidator for some date-fields on my ASP.NET pages.
The pages are localized and translated… so the date-formats need to change accordingly.

All was well… until I added a minimum and maximum value for the RangeValidator… something like 1-1-1900 and 1-1-2100.
I got a really cool error:

The value ‘1-1-1901’ of the MaximumValue property of ‘rangevalidatorStartDate’ cannot be converted to type ‘Date’.


So I figured… I need to localize the Min and Max date-string:
So I added this in the code behind.


rangevalidatorStartDate.MinimumValue = DateTime.MinValue.AddYears(1900).ToShortDateString();


The error was not fixed yet… because… you need to localize the parsing of the date according to Culture of the page.
Then the code looks like this.

void Page_Load(object sender, EventArgs e)


IFormatProvider culture = new
CultureInfo(Session[“MyCulture”].ToString(), true);


string minDate = DateTime.Parse(DateTime.MinValue.AddYears(1900).ToShortDateString(), culture).ToShortDateString();

string maxDate = DateTime.Parse(DateTime.MinValue.AddYears(2100).ToShortDateString(), culture).ToShortDateString();


rangevalidatorStartDate.MinimumValue = minDate;

rangevalidatorStartDate.MaximumValue = maxDate;




Then the markup looks like this.


ID=”txtStartDate” runat=”server”


ID=”StartdateFieldValidator” runat=”server”






        CssClass=”validation-message” Width=”7px”









ISV Buttons reappear after resize

MS CRM 4.0 has a great feature… disappearing ISV button label on a CRM Form when the form is not maximized.

However there is a problem…. the reappearance of ISV buttons after resizing the window.

Only a F5 (refresh) of the window will re-disappear the ISV buttons… since the OnLoad is re-executed.


In my case I have five button for Complaint Handling (never mind that).

When I open my complaint record, there is one ISV button… that’s correct

On Resize

Hey… this isn’t right.

Hit F5 and…

Ye… that’s right.

Now maximize again…

No… not good…




In the OnLoad handle hiding the ISV buttons in a separate funtion and attach the onresize to the form.



function HandleButtons() {

    // HandleButtons

    switch (parseInt(crmForm.all.statuscode.DataValue)) {

    case 3:        // Received

        HideIsvButton(new Array(“Assign to Investigator”, “Assign to Coordinator”, “Approve Complaint”, “Close Complaint”));


    case 6:     // Register




That’s all there’s to it.