2014年11月12日 星期三

ASP.NET C# Call Button1_Click(呼叫Button2_Click)

ASP.NET C# Call Button1_Click(呼叫Button2_Click)

C#:
// No "sender" or event args
public void Button2_Click(object sender, EventArgs e)
{
   button1_click(null, null);
}
// Button2's the sender and event args
public void Button2_Click(object sender, EventArgs e)
{  
   Button1_Click(sender, e);
}
// Button1's the sender and Button2's event args
public void Button2_Click(object sender, EventArgs e)
{  
   Button1_Click(this.Button1, e);
}

http://stackoverflow.com/questions/2152429/how-do-i-call-an-event-method-in-c

2014年11月11日 星期二

CRM2011 Setting Default Values in Form Customization(文字欄位設定預設值)

CRM2011 Setting Default Values in Form Customization(文字欄位設定預設值)



JavaScript:
function OnLoadForm()
{
    var formType = Xrm.Page.ui.getFormType();
    if(formType == 1){   //formType 1 = Create Form
        setField_Name();
    }
}
function setField_Name()
{
    Xrm.Page.getAttribute("name").setValue("howard_lai");
    //name=Entity Name, howard_lai=your value
}

CRM2011 Setting a default value on a lookup field(Lookup欄位設定預設值)

CRM2011 Setting a default value on a lookup field(Lookup欄位設定預設值)



JavaScript:
function OnLoadForm()
{
    var formType = Xrm.Page.ui.getFormType();
    if(formType == 1){   //formType 1 = Create Form
        setLookUp_Country();
    }
}
function setLookUp_Country()
{
    var country = Xrm.Page.getAttribute("countryid");
    var value = new Array();
    value[0] = new Object();
    value[0].id = "B842D214-3A33-E411-9096-00155D01017A";  // Guid Of That Look Up
    value[0].name = "JP";                                  // Name Of That Look Up
    value[0].entityType = "country";                // Entity Name Of That Look Up
    Xrm.Page.getAttribute("countryid").setValue(value);
}