Thursday, September 26, 2013

Report Viewer export to Excel/Word return blank/empty document

Issue
Exporting a report to Excel, Word or PDF was fine using Admin account. However, using a non-admin account, exporting report to Excel or Word will returned a blank/empty page but PDF was fine.

Solution
Navigate to the folder "C:\Users\<App Pool Identity>\AppData\Local\Temp", edit the security of this folder and add "Authenticated Users" with "Full Control " permissions.

How to check App pool identity?
In IIS Manager, click on Application Pools. Check the Identity for the particular app pool under the Identity column.

Wednesday, August 14, 2013

Textbox with Capital/Uppercase Letter

To convert the text input into the textbox by the user to be converted to capital/uppercase letter:

Design View
<form id="form1" runat="server">
<asp:ScriptManager ID="sc" runat="server"></asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" AutoPostBack="true"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>

Code Behind
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text.ToUpper();

}

Result

Monday, August 12, 2013

DropDownList

Designer View
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Select a colour : "></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</td>
</tr>
</table>

Add / bind data into dropdownlist
1. Manual binding
private void BindDropDownList()
{
DropDownList1.Items.Clear();
DropDownList1.Items.Insert(0, new ListItem("-SELECT-", "-1"));
DropDownList1.Items.Add(new ListItem("Red", "1"));
DropDownList1.Items.Add(new ListItem("Yellow", "2"));
DropDownList1.Items.Add(new ListItem("Green", "3"));
}

2. Using DataTable
private void BindDropDownList()
{
DataTable tableColour = GetTable();

DropDownList1.Items.Clear();
DropDownList1.Items.Insert(0, new ListItem("-SELECT-", "-1"));
DropDownList1.DataSource = tableColour;  //bind the ddp_dataview to dataview
DropDownList1.DataTextField = "Colour";
DropDownList1.DataValueField = "Colour Code";
DropDownList1.DataBind();
}

private DataTable GetTable()
{
DataTable table = new DataTable();
table.Columns.Add("Colour Code", typeof(int));
table.Columns.Add("Colour", typeof(string));

table.Rows.Add(1, "Red");
table.Rows.Add(2, "Yellow");
table.Rows.Add(3, "Green");

return table;
}

Result:

Monday, August 5, 2013

Make People Picker Look Like a TextBox

The default People Picker will look something like this;

So use the following CSS to make it look more like a default TextBox;


.ms-inputuserfield
{
font-size: 8pt;
font-family: Verdana,sans-serif;
}
   
div.ms-inputuserfield a
{
color: #000000;
text-decoration: none;
font-weight: normal;
font-style: normal;
}
   
div.ms-inputuserfield
{
border: 1px solid #a5a5a5;
position: relative;
padding-left: 1px;
padding-top: 2px;
}

As for the the People Picker control:
<SharePoint:PeopleEditor ID="PeopleEditor" CssClass="ms-inputuserfield" Width="360px" runat="server" AllowEmpty="false" MultiSelect="false" />

Exporting DLL from GAC via Command Prompt

To copy or export out a DLL in GAC;
  1. Launch a Command Prompt
  2. Browse to GAC_MSIL folder;
    • cd c:\windows\assembly\GAC_MSIL
  3. Each DLL in GAC will have its own folder, thus to get to the DLL, browse to the DLL folder;
    • cd <the name of the DLL>
  4. Different version of the DLL will be stored in different sub-folders. To check the available sub-folder enter "dir" in the Command Prompt
  5. Once identify the sub-folder, navigate into the sub-folder
    • cd <sub-folder name>
  6. Now you are able to export/copy out the DLL in this folder. To do so, use the following code;
    • copy *.dll C:\<preferred folder>\
  7. Done
Exporting DLL from GAC via Command Prompt