Monday, January 6, 2014

[SharePoint] Fix Attachment in New Form when the form was using Custom List Form

SharePoint New Form from a List

If a new form was created by using custom list form method (SharePoint Designer => Insert => SharePoint Controls => Custom List Form...)

When form is opened and users try to use the attachment function (Attach File), they received a warning "This form was customized not working with attachment."

To fix it, open the form in Code View,

Search for:
<table border="0" width="100%">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</table>

Replace with:
<div>
<span id="part1">
<table border="0" width="100%">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</table>
</span>
<SharePoint:AttachmentUpload runat="server" ControlMode="New"/>
<SharePoint:ItemHiddenVersion runat="server" ControlMode="New"/>
</div>


In bottom of the form, look for:
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<tr>
<td colspan="99" class="ms-vb">
<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
</td>
</tr>
</xsl:if>

Add code before/above those codes:
<tr id="idAttachmentsRow{''}">
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>Attachments:</nobr>
</H3>
</td>
<td valign="top" class="ms-formbody" width="80%">
<SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="New" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('i','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
<script>
          var elm = document.getElementById("idAttachmentsTable");
          if (elm == null || elm.rows.length == 0)
          document.getElementById("idAttachmentsRow").style.display='none';
        </script> </td>
</tr>

Friday, December 27, 2013

[Android] How to ROOT Sony Xperia Z TMobile C6606 4.2.2 Jelly Bean, Build# 10.3.1.E.0.191

Sony Xperia Z TMobile
Model number: C6606
Android version: 4.2.2
Build number: 10.3.1.E.0.191

Here what I did.

Prepare

1. Download and install Android SDK (http://developer.android.com/sdk/index.html or follow directions here: http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/)
2. Turn on USB debugging mode (Settings => About phone => Tab on the  Build number 6 or 7 times => Developer options appear => Select Developer options => Check USB debugging)
3. Install Xperia Z driver (download here: http://dl-developer.sonymobile.com/drivers/Xperia_Z_driver.zip) => install driver (to verify, use cmd line navigate to platform-tools and run "adb devices" => you should see your device ID)

Root

1. I downloaded and tried this version "rootkitZ_20131112.zip", but it failed (http://cubeundcube.blogspot.jp/2013/11/xperiarootz-so-02e-so-04e.html)
2. Then I downloaded and tried this version "rootkitXperia_20131207.zip" (https://mobile.twitter.com/cubeundcube/status/409191968795680770), but I got error (unknown adb...)
3. I copied "adb.exe" "AdbWinApi.dll" "AdbWinUsbApi.dll" from version #1 above to version #2 => then double click on adb.exe (try to copy these 3 files to different folder of the #2 method, if it doesn't work)
4. Re-run #2 install.bat (I confirmed this method works, rootkitXperia_20131207, but must run or copy the adb file over from method 1)
5. See attached for proof http://imageshack.us/a/img833/7803/ptut.png

Hope this helps someone. :)

Tuesday, October 8, 2013

[OUTLOOK] How to Setup Gmail Account on Microsoft Outlook

Tools => E-mail Account...
Add a new e-mail account => Next button => POP3 =>

[Screenshot 1]

User Information

  1. Enter your name
  2. Enter your email address
Logon Information
  1. Enter full gmail address as User Name
  2. enter your gmail account password
Server Information
  1. Incoming mail server (POP3): pop.gmail.com
  2. Outgoing mail server (SMTP): smtp.gmail.com
Then click on More Settings... button


[Screenshot 2]

Internet E-Mail Settings window => Click on Advanced tab
  1. Incoming server (POP3): 995
    Check the check box This server requires an encrypted connection (SSL)
  2. Outgoing server (SMTP): 465
    Check the check box This server requires an encrypted connection (SSL)

Tuesday, September 24, 2013

[JavaScript] Code Snippets

Redirect to the page with code below to close the window right away.
<script type="text/javascript">
window.open('','_self','');
window.close();
</script>


Thursday, May 2, 2013

[C#] How To Add JavaScript or CSS Dynamically To Page Header


Add JavaScript Dynamically To Page Header
string strJS = "<s" + "cript type=\"text/javascript\">";
strJS += "ADD YOUR SCRIPTS HERE";
strJS += "</" + "script>";
LiteralControl myJS = new LiteralControl();
myJS.Text = strJS;
Page.Header.Controls.Add(myJS);

Add CSS Dynamically To Page Header
string strCS = "<style type=\"text/css\">";
strCS += "ADD YOUR CSS CLASSES HERE";
strCS += "</style>";
LiteralControl myCS = new LiteralControl();
myCS.Text = strCS;
Page.Header.Controls.Add(myCS);
Short version: Page.Header.Controls.Add(new LiteralControl("<style type=\"text/css\"> CSS CLASS HERE }</style>"));

Tips: add /r and/or /n for new line

Wednesday, May 1, 2013

[C#] Convert String Array (string[]) to comma delimited string


string[] arrStrings = new string[] { "string1", "string2", "string3" };
string strDelimited = String.Join(",", arrStrings);

Result: string1,string2,string3

Thursday, April 18, 2013

[SharePoint] Upload File To Document Library Using SharePoint Object Model - Authenticate or Anonymous Access



using Microsoft.SharePoint;    //SharePoint
using System.IO;                //Stream

//if  Anonymous Access, document library must set to allow anonymous to add items
string strSharePointURL = "http://www.sharepoint.com";

if (txtUpload.HasFile)
{
    if (txtUpload.PostedFile.ContentLength > 0)
    {
        //string strFileName = txtUpload.PostedFile.FileName;
        string strFileName = txtUpload.FileName;

        Stream fStream = txtUpload.PostedFile.InputStream;
        byte[] bStream = new byte[fStream.Length];
        fStream.Read(bStream, 0, bStream.Length);
        fStream.Close();

        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            using (SPSite objSite = new SPSite(strSharePointURL))
            {
                using (SPWeb objWeb = objSite.OpenWeb())
                {
                    SPFolder libraryFolder = objWeb.Folders["Document_Library_Name"];
                    objWeb.AllowUnsafeUpdates = true;

                    libraryFolder.Files.Add(strFileName, bStream, true);
                }
            }
        });
    }
}
//In html code
<asp:FileUpload runat="server" id="txtUpload"/>