tag:blogger.com,1999:blog-32833602361156520022024-03-17T00:19:18.685+05:30Tips and TechniquesArticles of answer for your every question.Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.comBlogger155125tag:blogger.com,1999:blog-3283360236115652002.post-38452061607455752322015-07-09T19:33:00.000+05:302016-10-11T15:28:40.089+05:30Make custom calendar in c#calendar.aspx.cs<br />
<br />
<div class="prettyprint">
<span style="color: #444444;"><b>protected void Page_Load(object sender, EventArgs e)<br /> {<br /> if (!IsPostBack)<br /> {<br /> createcalendar(DateTime.Now.Month.ToString(), DateTime.Now.Year);<br /> }<br /> }<br /><br /> public void createcalendar(string mt, int yr)<br /> {<br /> DataTable dtSource = new DataTable();<br /> dtSource.Columns.Add("Sunday");<br /> dtSource.Columns.Add("Monday");<br /> dtSource.Columns.Add("Tuesday");<br /> dtSource.Columns.Add("Wednesday");<br /> dtSource.Columns.Add("Thursday");<br /> dtSource.Columns.Add("Friday");<br /> dtSource.Columns.Add("Saturday");<br /><br /> int year = yr;<br /><br /> int month = Convert.ToInt16(mt);<br /> for (int y = 1; y <= 12; y++)<br /> {<br /> ddlmonth.Items.Add(new ListItem(y.ToString(), y.ToString()));<br /> }<br /> ddlmonth.SelectedValue = month.ToString();<br /> lblyear.Text = Convert.ToString(year);<br /> int DaysInMonth = DateTime.DaysInMonth(year, month);<br /><br /> int i = 1;<br /><br /><br /> for (int weak = 0; weak <= 5; weak++)<br /> {<br /> DataRow newday = dtSource.NewRow();<br /> for (int day = 1; day <= 7; day++)<br /> {<br /> if (i > DaysInMonth) break;<br /> DateTime dDate = DateTime.ParseExact(i.ToString() + "/" + month.ToString() + "/" + year.ToString(), "d/M/yyyy", null);<br /> DayOfWeek dayWeek = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(dDate);<br /> newday[dayWeek.ToString()] = i.ToString();<br /> i++;<br /><br /> if (dayWeek.ToString() == "Saturday") break;<br /> }<br /> dtSource.Rows.Add(newday);<br /> if (i > DaysInMonth) break;<br /> }<br /><br /> WeekRepeater.DataSource = dtSource;<br /> WeekRepeater.DataBind();<br /><br /> hdnyear.Value = year.ToString();<br /><br /><br /> }<br /> protected void lnkprev_Click(object sender, EventArgs e)<br /> {<br /> createcalendar(ddlmonth.SelectedValue, Convert.ToInt16(hdnyear.Value) - 1);<br /> }<br /> protected void lnknext_Click(object sender, EventArgs e)<br /> {<br /> createcalendar(ddlmonth.SelectedValue, Convert.ToInt16(hdnyear.Value) + 1);<br /> }<br /> protected void ddlmonth_SelectedIndexChanged(object sender, EventArgs e)<br /> {<br /> createcalendar(ddlmonth.SelectedValue, Convert.ToInt16(hdnyear.Value));<br /> }<br /> protected void btnshow_Click(object sender, EventArgs e)<br /> {<br /> createcalendar(ddlmonth.SelectedValue, Convert.ToInt16(hdnyear.Value));<br /> }<br />
<br />
</b></span></div>
calendar.aspx<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="color: #444444;"><b><br /></b></span>
<br />
<span style="color: #444444;"><b><div id="calbg"><br /> <div id="calcontent"><br /> <table><br /> <tr><br /> <td><br /> <asp:TextBox runat="server" ID="txtdatefrom"></asp:TextBox><br /> </td><br /> <td><br /> <asp:TextBox runat="server" ID="txtdateto"></asp:TextBox><br /> </td><br /> <td><br /> <asp:Button runat="server" ID="btnshow" Text="SHOW" OnClick="btnshow_Click" /><br /> </td><br /> </tr><br /> </table><br /> <table><br /> <tr><br /> <td><br /> <asp:LinkButton runat="server" ID="lnkprev" Text="<" OnClick="lnkprev_Click"></asp:LinkButton><br /> </td><br /> <td colspan="5"><br /> <asp:DropDownList runat="server" ID="ddlmonth" OnSelectedIndexChanged="ddlmonth_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList><br /> <asp:Label runat="server" ID="lblyear"></asp:Label><br /> </td><br /> <td><br /> <asp:LinkButton runat="server" ID="lnknext" Text=">" OnClick="lnknext_Click"></asp:LinkButton><br /> </td><br /> </tr><br /> </table><br /> <asp:Repeater ID="WeekRepeater" runat="server" OnItemDataBound="WeekRepeater_ItemDataBound"><br /> <HeaderTemplate><br /> <table><br /><br /> <tr><br /> <th>Su<br /> </th><br /> <th>Mo<br /> </th><br /> <th>Tu<br /> </th><br /> <th>Wed<br /> </th><br /> <th>Thu<br /> </th><br /> <th>Fr<br /> </th><br /> <th>Sa<br /> </th><br /> </tr><br /> </HeaderTemplate><br /> <ItemTemplate><br /> <tr><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label1" Text='<%# Eval("Sunday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label2" Text='<%# Eval("Monday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label3" Text='<%# Eval("Tuesday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label4" Text='<%# Eval("Wednesday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label5" Text='<%# Eval("Thursday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label6" Text='<%# Eval("Friday") %>' /><br /> </td><br /> <td bgcolor="#CCFFCC"><br /> <asp:Label runat="server" ID="Label7" Text='<%# Eval("Saturday") %>' /><br /> </td><br /> </tr><br /> </ItemTemplate><br /> </asp:Repeater><br /> <asp:HiddenField runat="server" ID="hdnyear" /><br /> </div><br /></div></b></span>
</b></span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-5581230675839688242014-04-22T14:23:00.004+05:302014-04-22T14:25:30.558+05:30c# - Convert comma separated string to array<span style="font-family: "Trebuchet MS",sans-serif;">Split separates strings. Often strings have delimiter characters in their data. Split handles splitting upon string and character delimiters.Methods can be combined. Using IndexOf and Substring together is another way to split strings.<br /><b>e.g.</b><br />Use Split to separate parts from a string. If your input is "A B C", split on the space to get an array of "A", "B" and "C".</span><
<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">string str = "1,2,3,4";<br /><br /> // 1st way<br /> string[] strArray = str.Split(new char[] { ',' });<br /> int[] intArray = new int[strArray.Length];<br /> for (int i = 0; i < strArray.Length; i++)<br /> {<br /> intArray[i] = int.Parse(strArray[i]);<br /> }<br /><br /> // 2nd way<br /> string[] array = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);</span>
</b></span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com1tag:blogger.com,1999:blog-3283360236115652002.post-13011276457179024822014-04-05T18:06:00.001+05:302014-04-05T18:11:45.523+05:30contextual help dialogs using HelpProvider Class<span style="font-family: "Trebuchet MS",sans-serif;">The HelpProvider control offers contextual help dialogs. Sometimes a user wants a verbose description of a control. With HelpProvider we provide this description by adding a Help button and setting some properties.<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
using System;<br />using System.Drawing;<br />using System.Windows.Forms;</b></span></span><br />
<a name='more'></a><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><br />public class Form1 : System.Windows.Forms.Form<br />{<br /> private System.Windows.Forms.TextBox addressTextBox;<br /> private System.Windows.Forms.Label label2;<br /> private System.Windows.Forms.TextBox cityTextBox;<br /> private System.Windows.Forms.Label label3;<br /> private System.Windows.Forms.TextBox stateTextBox;<br /> private System.Windows.Forms.TextBox zipTextBox;<br /> private System.Windows.Forms.HelpProvider helpProvider1;<br /> private System.Windows.Forms.Label helpLabel;<br /><br /> [STAThread]<br /> static void Main() <br /> {<br /> Application.Run(new Form1());<br /> }<br /><br /> public Form1()<br /> {<br /> this.addressTextBox = new System.Windows.Forms.TextBox();<br /> this.helpLabel = new System.Windows.Forms.Label();<br /> this.label2 = new System.Windows.Forms.Label();<br /> this.cityTextBox = new System.Windows.Forms.TextBox();<br /> this.label3 = new System.Windows.Forms.Label();<br /> this.stateTextBox = new System.Windows.Forms.TextBox();<br /> this.zipTextBox = new System.Windows.Forms.TextBox();<br /><br /> // Help Label <br /> this.helpLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;<br /> this.helpLabel.Location = new System.Drawing.Point(8, 80);<br /> this.helpLabel.Size = new System.Drawing.Size(272, 72);<br /> this.helpLabel.Text = "Click the Help button in the title bar, then click a control " + <br /> "to see a Help tooltip for the control. Click on a control and press F1 to invoke " +<br /> "the Help system with a sample Help file.";<br /><br /> // Address Label <br /> this.label2.Location = new System.Drawing.Point(16, 8);<br /> this.label2.Size = new System.Drawing.Size(100, 16);<br /> this.label2.Text = "Address:";<br /><br /> // Comma Label <br /> this.label3.Location = new System.Drawing.Point(136, 56);<br /> this.label3.Size = new System.Drawing.Size(16, 16);<br /> this.label3.Text = ",";<br /><br /> // Create the HelpProvider. <br /> this.helpProvider1 = new System.Windows.Forms.HelpProvider();<br /><br /> // Tell the HelpProvider what controls to provide help for, and <br /> // what the help string is. <br /> this.helpProvider1.SetShowHelp(this.addressTextBox, true);<br /> this.helpProvider1.SetHelpString(this.addressTextBox, "Enter the street address in this text box.");<br /><br /> this.helpProvider1.SetShowHelp(this.cityTextBox, true);<br /> this.helpProvider1.SetHelpString(this.cityTextBox, "Enter the city here.");<br /><br /> this.helpProvider1.SetShowHelp(this.stateTextBox, true);<br /> this.helpProvider1.SetHelpString(this.stateTextBox, "Enter the state in this text box.");<br /><br /> this.helpProvider1.SetShowHelp(this.zipTextBox, true);<br /> this.helpProvider1.SetHelpString(this.zipTextBox, "Enter the zip code here.");<br /><br /> // Set what the Help file will be for the HelpProvider. <br /> this.helpProvider1.HelpNamespace = "mspaint.chm";<br /><br /> // Sets properties for the different address fields. <br /><br /> // Address TextBox <br /> this.addressTextBox.Location = new System.Drawing.Point(16, 24);<br /> this.addressTextBox.Size = new System.Drawing.Size(264, 20);<br /> this.addressTextBox.TabIndex = 0;<br /> this.addressTextBox.Text = "";<br /><br /> // City TextBox <br /> this.cityTextBox.Location = new System.Drawing.Point(16, 48);<br /> this.cityTextBox.Size = new System.Drawing.Size(120, 20);<br /> this.cityTextBox.TabIndex = 3;<br /> this.cityTextBox.Text = "";<br /><br /> // State TextBox <br /> this.stateTextBox.Location = new System.Drawing.Point(152, 48);<br /> this.stateTextBox.MaxLength = 2;<br /> this.stateTextBox.Size = new System.Drawing.Size(32, 20);<br /> this.stateTextBox.TabIndex = 5;<br /> this.stateTextBox.Text = "";<br /><br /> // Zip TextBox <br /> this.zipTextBox.Location = new System.Drawing.Point(192, 48);<br /> this.zipTextBox.Size = new System.Drawing.Size(88, 20);<br /> this.zipTextBox.TabIndex = 6;<br /> this.zipTextBox.Text = "";<br /><br /> // Add the controls to the form. <br /> this.Controls.AddRange(new System.Windows.Forms.Control[] {<br /> this.zipTextBox, this.stateTextBox,<br /> this.label3, this.cityTextBox,<br /> this.label2, this.helpLabel,<br /> this.addressTextBox});<br /><br /> // Set the form to look like a dialog, and show the HelpButton. <br /> this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;<br /> this.HelpButton = true;<br /> this.MaximizeBox = false;<br /> this.MinimizeBox = false;<br /> this.ClientSize = new System.Drawing.Size(292, 160);<br /> this.Text = "Help Provider Demonstration";<br /> }<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<span style="font-family: "Trebuchet MS",sans-serif;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-49UZVLrmpJE/Uz_5ir1upJI/AAAAAAAABhs/qrrqFaem_1M/s1600/helpprovider.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-49UZVLrmpJE/Uz_5ir1upJI/AAAAAAAABhs/qrrqFaem_1M/s1600/helpprovider.png" /></a></div>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />We used the HelpProvider control to provide contextual help in a Windows Forms program. By adding the Help button and then setting the HelpString property that is offered by the HelpProvider instance, a help mode is enabled.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br />For More : <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.helpprovider.aspx" target="_blank">HelpProvider Class</a></span>Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-12116986993427275702014-04-05T11:22:00.002+05:302014-04-05T11:26:12.515+05:30How to extract a portion of a string variable in C#<span style="font-family: "Trebuchet MS",sans-serif;">There are many ways to do this, i am exaplaining two of them.<br /><br /><br /><b>1. String.Remove Method (Int32, Int32)</b><br /><br />Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.<br /><br />Syntax :<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public string Remove(<br /> int startIndex,<br /> int count<br />)<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
example :<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
My string is "C:\Program Files\Microsoft Visual Studio\VSS\users" and i want to <br /><br />"C:\Program Files\Microsoft Visual Studio\VSS" then<br /><br />
string s = "svn://mcdssrv/repos/currecnt/class/MBackingBean.java";<br /> s.Remove(s.LastIndexOf('\'));<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
<b>2. String.Substring Method </b><br /><br />Retrieves a substring from this instance.<br /><br />Substring takes the start index (zero-based) and the number of characters you want to copy.<br /><br />example :<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
string str = "C:\Program Files\Microsoft Visual Studio\VSS\users";<br /> str = str.Substring(0, str.LastIndexOf('\') + 1);<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
<br /><b>3. By using both method</b><br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
var subString = "C:\Program Files\Microsoft Visual Studio\VSS\users";<br /> subString = subString.Remove(subString.LastIndexOf('\')+1);</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-46286653004072777412014-03-25T13:24:00.000+05:302014-03-25T13:30:56.166+05:30How to Display the Actual Number with Decimal<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">When you configure how numbers display, you select the number of decimal places to show. Crystal Reports then rounds the display value to that decimal position and that is what you see. </span></span></span><br />
<br />
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">But what if you want to display the actual number? If the original number has no decimal places, you want to see that. If the original has three decimal places, you want to see all three.</span></span></span><br />
<br />
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">You can do this using conditional formatting.</span></span></span><br />
<a name='more'></a><div class="postentry">
<ol>
<li><div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">Right click on the number field and select <b>Format Field</b> from the pop up menu. You see the Format Editor dialog.</span></span></span><br />
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;"><br />
</span></span></span></div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><img alt="" src="http://crystaltricks.com/wordpress/wp-content/uploads/2010/11/110910_2115_HowtoDispla1.png" /></span></span></li>
<li>
<div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">On the Number tab, click the Customize button. You see the Custom Style dialog.</span></span></span><br />
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;"><br />
</span></span></span></div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><img alt="" src="http://crystaltricks.com/wordpress/wp-content/uploads/2010/11/110910_2115_HowtoDispla2.png" /><br />
</span></span></li>
<li>
<div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">On the Number tab, click the Conditional Format button next to the Rounding option. Enter the following formula:</span></span></span><br />
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;"><br />
</span></span></span></div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>If CurrentFieldValue = Int(CurrentFieldValue)<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Then 0<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Else<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>If<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>CurrentFieldValue * 10 = Int(CurrentFieldValue * 10)<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Then 1<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Else<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>If<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>CurrentFieldValue * 100 = Int(CurrentFieldValue * 100)<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Then 2<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Else<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>If<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>CurrentFieldValue * 1000 = Int(CurrentFieldValue * 1000)<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Then 3<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Else<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>If<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>CurrentFieldValue * 10000 = Int(CurrentFieldValue * 10000)<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Then 4<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Else<br />
</b></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: font-family: Courier New;"><b><span style="color: black;">DefaultAttribute </span><br />
</b></span></span></span></li>
<li><span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">Click on the Conditional Format button next to the Decimal option and paste the same formula.<br />
</span></span></span></li>
<li>
<div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">Click on OK twice to return to your report and view your formatting changes:<br />
</span></span></span></div>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><img alt="" src="http://crystaltricks.com/wordpress/wp-content/uploads/2010/11/110910_2115_HowtoDispla3.png" /></span></span>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;"></span></span></span></li>
</ol>
<span style="font-size: small;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black;">This will show the correct values up to four decimal places. If you need to accommodate more decimal places, you can expand the formula by adding more IF statements.</span></span></span><br />
<ol>
</ol>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-46359169131466547262014-03-21T14:31:00.002+05:302014-03-21T17:56:14.389+05:30ToText Function in Crystal Report<h2 class="posttitle">
<span style="font-family: "Trebuchet MS",sans-serif;">
ToText Function</span></h2>
<div class="postentry">
<h2>
<span style="font-family: "Trebuchet MS",sans-serif;">
Uses</span></h2>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">The ToText function can be used to convert number, date, boolean, or time values to a string (text). It provides you with controls that let you control how the resulting string looks.</span></div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">It’s mostly used for concatenation (for example, you can create a title for your report that shows the records covered, or a group name that shows the date range included.)</span></div>
<ul>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Add parameters to a Report title</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Control how group names appear (you can force your dates to appear in the format 3/7/10 or 20100901. </span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span></ul>
<a name='more'></a><h2>
<span style="font-family: "Trebuchet MS",sans-serif;">
ToText for Boolean Values</span></h2>
<div style="margin-left: 19pt;">
<table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 155px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Syntax</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ToText(x)</span></td>
</tr>
</tbody>
</table>
</div>
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">
Examples</span></h3>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 148px;"></col></colgroup><colgroup><col style="width: 403px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({Completed})</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>True</b></span> when the field Completed is true.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>False</b></span> when the field Completed is false.</span></td>
</tr>
</tbody>
</table>
</div>
<h2>
<span style="font-family: "Trebuchet MS",sans-serif;">
ToText for Numbers (and Currency)</span></h2>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 121px;"></col></colgroup><colgroup><col style="width: 68px;"></col></colgroup><colgroup><col style="width: 419px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Syntax</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Variable</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Optional</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ToText(x, y, z, w)</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>x</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The number to convert to text</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>y</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The number of decimal places to include in result (optional). The value will be rounded to that decimal place.</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>z</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The character to use as the thousands separator. If you don’t specify one, it will use your application default. (Optional.)</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>w</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The character to use as the decimal separator. If you don’t specify one, it will use your application default. (Optional.)</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">
Examples</span></h3>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 382px;"></col></colgroup><colgroup><col style="width: 227px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText(12345.678)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“12345.678?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText(12345.678,2)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“12345.67?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText(12345.678,0)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“12345?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText(12345.678, 0, ‘,’, ‘.’)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“12,345.67?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText(12345.678,0,”")</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“12345?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: 10pt;"><span style="color: green;"><b>“Time Logged for Change # ” &amp; ToText(12345.567,0,”")</b></span><span style="color: #884411;"><br />
</span></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“Time Logged for Change # 12345?</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<h2>
<span style="font-family: "Trebuchet MS",sans-serif;">
ToText for Dates</span></h2>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 121px;"></col></colgroup><colgroup><col style="width: 68px;"></col></colgroup><colgroup><col style="width: 419px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Syntax</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Variable</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Optional</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ToText(x, y)</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>x</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The date value to be converted.</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>y</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>A text string that defines how the value is to be formatted. (Optional)</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">
Examples (where datefield = January 15, 2011)</span></h3>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 276px;"></col></colgroup><colgroup><col style="width: 238px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({datefield}, “yyyyMM”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“201101?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({datefield},”dd-MMM-yyyy”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“15-Jan-2011?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({datefield},”dd MMM yyyy”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“15 Jan 2011?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({datefield},”MM/dd/yy”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“01/15/11?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({datefield},”dddd, MMM d, yyyy”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“Saturday, Jan 1, 2011?</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">This looks a little confusing at first. Sometimes d’s return the day of the week and sometimes they return a number. This is because the format is determined by the specific pattern:</span></div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 70px;"></col></colgroup><colgroup><col style="width: 539px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Pattern</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">d</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Numeric day of month without leading zero (1, 7, 31)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">dd</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Numeric day of month with leading zero (01, 07, 31)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ddd</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Three day abbreviation of day of week (Mon, Sat)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">dddd</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Full name of day of week (Monday, Saturday)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">M</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Numeric month without leading zero (1, 7, 12)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">MM</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Numeric month with leading zero (01, 07, 12)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">MMM</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Three letter abbreviation of month (Jan, Feb, Mar)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">MMMM</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Full name of month (January, February, March)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">yy</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Last two digits of year (11, 14, 22)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">yyyy</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Full four digits of year (2011, 2014, 2022)</span></td>
</tr>
</tbody>
</table>
</div>
<h2>
<span style="font-family: "Trebuchet MS",sans-serif;">
ToText for Times</span></h2>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 121px;"></col></colgroup><colgroup><col style="width: 68px;"></col></colgroup><colgroup><col style="width: 419px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Syntax</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Variable</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Optional</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ToText(x, y, z, w)</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>x</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>The time value to be converted.</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>y</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>A text string that defines how the value is to be formatted. (Optional)</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>z</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>A text string defining the AM string. (Optional)</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b> </b></span></span><br />
</td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>w</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>A text string defining the PM string. (Optional)</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">
Examples (where timefield =2:43:23 p.m.)</span></h3>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 288px;"></col></colgroup><colgroup><col style="width: 238px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({timefield}, “HH:mm:ss”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“14:43:23?</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({timefield}, “hh:mm:ss tt”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“02:43:23 PM”</b></span></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({timefield},”h*mm*ss tt”,’am’, ‘pm’)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“2*43*23 pm”</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">Here are the patterns used by ToText when converting time:</span></div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 67px;"></col></colgroup><colgroup><col style="width: 542px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Pattern</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">h</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Hours without leading zeros in 12 hour format (1, 7, 12)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">hh</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Hours with leading zeros in 12 hour format (01, 07, 12)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">H</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Hours without leading zeros in 24 hour format (1, 12, 17, 24)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">HH</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Hours with leading zeros in 24 hour format (01, 12, 17, 24)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">m</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Minutes without leading zeros (5, 15, 55)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">mm</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Minutes with leading zeros (05, 15, 55)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">s</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Seconds without leading zeros (5, 15, 55)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">ss</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Seconds with leading zeros (05, 15, 55)</span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">t, tt</span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;">Includes a single or multi-character AM/PM string.</span></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">If you want to include any of the pattern characters in your resulting string, you can. You just need to enclose them in quotes.</span></div>
<div style="margin-left: 19pt;">
<span style="font-family: "Trebuchet MS",sans-serif;">
</span><table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 295px;"></col></colgroup><colgroup><col style="width: 238px;"></col>
</colgroup>
<tbody>
<tr>
<td style="border: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: solid #a3a3a3 1.0pt; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><b>Result</b></span></td>
</tr>
<tr>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: solid #a3a3a3 1.0pt; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>ToText({timefield}, “hh ‘h’ mm ‘min’ ss ‘sec’”)</b></span></span></td>
<td style="border-bottom: solid #a3a3a3 1.0pt; border-left: none; border-right: solid #a3a3a3 1.0pt; border-top: none; padding: 5px;"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: green;"><b>“02 h 43 min 23 sec”</b></span></span></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-left: 19pt;">
</div>
<div style="margin-left: 19pt;">
</div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-38314874350041102562014-03-21T14:12:00.000+05:302014-03-21T14:16:55.417+05:30List of FUNCTIONS in Crystal Report<span style="font-family: "Trebuchet MS",sans-serif;">Crystal
Reports provides many <span style="font-weight: bold;"><b>FUNCTIONS</b></span>
for extracting information from the files. </span><br />
<br />
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">List of Functions </span></h3>
<ul>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Abs(x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Average([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Average(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Average(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Average(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
BeforeReadingRecords</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Count([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Count(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Count(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Count(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Date (yyyy, mm, dd)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Day (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
DayOfWeek (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
GroupNumber</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
IsNull</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Length(x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
LowerCase (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Maximum([array]) Maximum(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Maximum(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Maximum(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Minimum([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Minimum(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Minimum(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Minimum(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Month (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Next</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
NextIsNull</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
NumericText(fieldname)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PageNumber</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationStdDev([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationStdDev(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationStdDev(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationStdDev(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationVariance([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationVariance(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationVariance(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PopulationVariance(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Previous</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PreviousIsNull</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
PrintDate</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
RecordNumber</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Remainder(numerator, denominator)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ReplicateString(x,n)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Round(x, # places)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Round(x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
StdDev([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
StdDev(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
StdDev(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
StdDev(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Sum([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Sum(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Sum(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Sum(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Today</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ToNumber (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ToText (x, # places)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ToText (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ToWords(x, # places)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
ToWords(x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
TrimLeft (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
TrimRight (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Truncate (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
UpperCase (x)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Variance([array])</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Variance(field, condField)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Variance(field, condField, "condition")</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Variance(field)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
WhilePrintingRecords</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
WhileReadingRecords</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">
Year (x)</span></li>
</ul>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-48345446573676715662014-03-19T11:29:00.001+05:302014-03-19T11:38:27.791+05:30Date field in the format of D D M M Y Y Y Y in Crystal Report<span style="font-family: "Trebuchet MS",sans-serif;">The default format gives me the date as ddmmyyyy I need to figure out a way to print the date in the format of D D M M Y Y Y Y.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /> </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-GXJ9QlQQlhU/UykxvGnSRXI/AAAAAAAABhI/z2umg_aStYM/s1600/hdfcbank_cts.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-GXJ9QlQQlhU/UykxvGnSRXI/AAAAAAAABhI/z2umg_aStYM/s1600/hdfcbank_cts.jpg" height="288" width="640" /></a></div>
<br />
<span style="font-family: "Trebuchet MS",sans-serif;">To achieve this i need create a new formula field.<br /><br />Now lets look at the formula.<br /><br />totext({YourDateFieldHere}, "ddmmyyyy")<br /><br />Then create a new formula and paste the following<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
mid({@formulaDate},1,1)&" "&mid({@formulaDate},2,1)&" <br />"&mid({@formulaDate},3,1)&" "&mid({@formulaDate},4,1)&" <br />"&mid({@formulaDate},5,1)&" "&mid({@formulaDate},6,1)&" <br />"&mid({@formulaDate},7,1)&" "&mid({@formulaDate},8,1)<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"></span></b></span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">explanation for mid function</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><br />Local StringVar x :=totext(Currentdate, "</span><span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-family: "Trebuchet MS",sans-serif;">ddmmyyyy</span>")<br />Local StringVar y;<br /><br />//Start at position 2, go to the end of the string<br /><br />y := Mid (x, 2); //y is now "9032014"<br /><br />//Start at position 2, extract 1 character<br /><br />y := Mid (x, 2, 1) //y is now "9"</span>
</b></span></span>Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-46452873340378145772014-03-07T14:54:00.000+05:302014-03-19T11:35:02.531+05:30Table with fixed header on scroll<html>
<body>
<div style="border-collapse: collapse; border: 1px solid black; height: 100px; margin: 0; overflow: hidden; padding: 0; width: 519px;">
<table style="background-color: grey; border-collapse: collapse; color: white; height: 20px; margin: 0; padding: 0; text-align: left; width: 517px;">
<colgroup>
<col width="200px"></col>
<col width="150px"></col>
<col width="150px"></col>
<col width="16px"></col>
</colgroup>
<tbody>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<th style="border-collapse: collapse; margin: 0; padding: 0;">
Column 1
</th>
<th style="border-collapse: collapse; margin: 0; padding: 0;">
Column 2
</th>
<th style="border-collapse: collapse; margin: 0; padding: 0;">
Column 3
</th>
<th style="border-collapse: collapse; margin: 0; padding: 0;">
</th>
</tr>
</tbody>
</table>
<div style="border-collapse: collapse; height: 77px; margin: 0; overflow: auto; padding: 0; width: 517px;">
<table style="border-collapse: collapse; margin: 0; padding: 0; width: 500px;">
<colgroup>
<col width="200px"></col>
<col width="150px"></col>
<col width="150px"></col>
</colgroup>
<tbody style="border-collapse: collapse; margin: 0; padding: 0;">
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row A-1
</td>
<td style="border: 1px solid lightgrey;">
Row A-2
</td>
<td style="border: 1px solid lightgrey;">
Row A-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row B-1
</td>
<td style="border: 1px solid lightgrey;">
Row B-2
</td>
<td style="border: 1px solid lightgrey;">
Row B-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row C-1
</td>
<td style="border: 1px solid lightgrey;">
Row C-2
</td>
<td style="border: 1px solid lightgrey;">
Row C-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row D-1
</td>
<td style="border: 1px solid lightgrey;">
Row D-2
</td>
<td style="border: 1px solid lightgrey;">
Row D-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row E-1
</td>
<td style="border: 1px solid lightgrey;">
Row E-2
</td>
<td style="border: 1px solid lightgrey;">
Row E-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row F-1
</td>
<td style="border: 1px solid lightgrey;">
Row F-2
</td>
<td style="border: 1px solid lightgrey;">
Row F-3
</td>
</tr>
<tr style="border-collapse: collapse; margin: 0; padding: 0;">
<td style="border: 1px solid lightgrey;">
Row G-1
</td>
<td style="border: 1px solid lightgrey;">
Row G-2
</td>
<td style="border: 1px solid lightgrey;">
Row G-3
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body></html><br />
<a name='more'></a>
The code is produced with the following:<br />
<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<html><br /><body><br /> <div style="margin: 0; padding: 0; border-collapse: collapse; width: 519px; height: <br /><br />100px; overflow: hidden; border: 1px solid black;"><br /> <table style="margin: 0; padding: 0; border-collapse: collapse; color: White; width: <br /><br />517px; height: 20px; text-align: left; background-color: Grey;"><br /> <colgroup><br /> <col width="200px" /><br /> <col width="150px" /><br /> <col width="150px" /><br /> <col width="16px" /><br /> </colgroup><br /> <tbody><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <th style="margin: 0; padding: 0; border-collapse: collapse;">Column 1<br /> </th><br /> <th style="margin: 0; padding: 0; border-collapse: collapse;">Column 2<br /> </th><br /> <th style="margin: 0; padding: 0; border-collapse: collapse;">Column 3<br /> </th><br /> <th style="margin: 0; padding: 0; border-collapse: collapse;"></th><br /> </tr><br /> </tbody><br /> </table><br /> <div style="margin: 0; padding: 0; border-collapse: collapse; width: 517px; height: <br /><br />77px; overflow: auto;"><br /> <table style="margin: 0; padding: 0; border-collapse: collapse; width: 500px;"><br /> <colgroup><br /> <col width="200px" /><br /> <col width="150px" /><br /> <col width="150px" /><br /> </colgroup><br /> <tbody style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row A-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row A-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row A-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row B-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row B-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row B-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row C-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row C-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row C-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row D-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row D-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row D-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row E-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row E-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row E-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row F-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row F-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row F-3<br /> </td><br /> </tr><br /> <tr style="margin: 0; padding: 0; border-collapse: collapse;"><br /> <td style="border: 1px solid lightgrey;">Row G-1<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row G-2<br /> </td><br /> <td style="border: 1px solid lightgrey;">Row G-3<br /> </td><br /> </tr><br /> </tbody><br /> </table><br /> </div><br /> </div><br /><br /></body><br /></html> <br />
</b></span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-67414658352812521352014-02-22T13:16:00.000+05:302014-02-22T13:39:37.077+05:30Overloading and Overriding in C# with real world example<span style="font-family: "Trebuchet MS",sans-serif;">In my early day career in many interviews I asked same question, what is overloading and overriding so decided to write this small article which may help someone. We will see here in detail about the overloading, overriding and then differences between them.<br /><br /><b>Overloading:</b> is the mechanism to have more than one method with same name but with different signature (parameters). A method can be overloaded on the basis of following properties</span><br />
<ol>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Have different number of parameter</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Having same number of parameters but of different type</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Having same number and type of parameters but in different orders </span></li>
</ol>
<span style="font-family: "Trebuchet MS",sans-serif;"></span><br />
<a name='more'></a><span style="font-family: "Trebuchet MS",sans-serif;"><br />A method cannot be overloaded on the basis of</span><br />
<ol>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Different return type</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Different access modifier</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Normal and optional parameters </span></li>
</ol>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />Some example valid examples:</span>
<br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public List<Customer> FindCustomer(String customer_name)<br />{<br /> // your code<br />}<br />public List<Customer> FindCustomer(Int32 customer_Id)<br />{<br /> // your code<br />}<br /><br />public List<Customer> FindCustomer(String customer_name, String city)<br />{<br /> // your code<br />}<br />public List<Customer> FindCustomer(String customer_name, Int32 customer_Id)<br />{<br /> // your code<br />}<br /><br />public List<Customer> FindCustomer(String customer_name, String city, String zip)<br />{<br /> // your code<br />}<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">Following are invalid overloading because we can not overload on the basis of different return type</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public List<Customer> FindCustomer(String customer_name)<br />
{<br />
// your code<br />
}<br />
public Customer FindCustomer(String customer_name)<br />
{<br />
// your code<br />
}<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">Following are also invalid overloading, because we cannot overload on the basis of access modifier</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public List<Customer> FindCustomer(String customer_name)<br />
{<br />
// your code<br />
}<br />
private List<Customer> FindCustomer(String customer_name)<br />
{<br />
// your code<br />
}<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">Following are also not valid, because we cannot overload normal and optional parameter</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public List<Customer> FindCustomer(String customer_name)<br />
{<br />
// your code<br />
}<br />
private List<Customer> FindCustomer(String customer_name = String.Empty)<br />
{<br />
// your code<br />
}</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">In the same way we can overload constructor of a class by defining more than one constructor with different parameters which is known as constructor overloading.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;"><b>Overriding:</b> Overriding can be done in derived class, an override method provides a new implementation of a method inherited from parent class.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">To override a method in base (parent) class it must be</span><br />
<ul>
<li> virtual</li>
<li> abstract</li>
<li> override </li>
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />We cannot override a base method which is in base class as</span><br />
<ul>
<li> non-virtual</li>
<li> static </li>
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />We cannot use the following modifiers to modify an override method in derived class</span><br />
<ul>
<li> new</li>
<li> static</li>
<li> virtual</li>
<li> abstract </li>
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />Let's see it with example:<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public class Square <br />{<br /> public double side;<br /> // Constructor:<br /> public Square(double side) <br /> { this.side = x; }<br /><br /> public virtual double Area() <br /> { return side * side ; }<br />}<br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">Note Area method is defined with virtual so it can be overridden in derived class, now lets derive a class cube from square and override it's Area method
</span><br />
<div class="prettyprint">
<b><span style="font-family: "Trebuchet MS",sans-serif;">
class Cube: Square <br />{<br /> // Constructor:<br /> public Cube(double side): base(x) { }<br /> // Calling the Area base method:<br /> public override double Area() <br /> { return (6*(base.Area())); }<br />}</span><br />
</b></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
<b>Conclusion:</b></span><br />
<ul>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overloading can be done in same class</span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overriding can be done in parent and derived class</span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overloading in used when we need same method in same class with different parameters</span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overriding is used when we need to redefine a method that has already been defined in parent class (using the exact same signature</span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overloading is resolved at compile time</span></li>
<span style="font-family: "Trebuchet MS",sans-serif;">
</span>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Overriding is resolved at run time </span></li>
</ul>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com1tag:blogger.com,1999:blog-3283360236115652002.post-43620906302134275632014-02-06T12:34:00.000+05:302014-02-06T12:35:57.883+05:30Difference between CTE and Temp Table<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">CTE </span></h3>
<ul style="text-align: left;">
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE is un-materialized/ non-indexable (cannot create indexes on CTE)</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE is logical/disposableView</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE persists only till the very next query</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE cannot have constraints</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE is mostly used for recursion, as CTE can call itself</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">CTE resists in memory</span></li>
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"></span><ul style="text-align: left;">
</ul>
<b><span style="font-family: "Trebuchet MS",sans-serif;"> Example </span></b>
<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">By using CTE<br /><br /> ;With CTE1(Addr, FullName, Age)<br /> AS<br /> (<br /> SELECT Addr.Addr, Emp.FullName, Emp.Age from Address Addr<br /> INNER JOIN Employee Emp ON Emp.EID = Addr.EID<br /> )<br /> SELECT * FROM CTE1 --Using CTE<br /> WHERE CTE1.Age > 50<br /> ORDER BY CTE1.FullName</span></b></span></div>
<h3>
<span style="font-family: "Trebuchet MS",sans-serif;">Temp Table</span> </h3>
<ul style="text-align: left;">
<li><span style="font-family: "Trebuchet MS",sans-serif;">Temp table gets stored in temp table</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Temp table persists till the current connection ends</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Temp table can be referred in sub procedure</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Temp table can have constraints,indexes and primary defined</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Indexes can be implemented in Temp Table</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Data can be updated in Temp Table</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Temp Tables are stored in disk</span></li>
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"></span><ul style="text-align: left;">
</ul>
<span style="font-family: "Trebuchet MS",sans-serif;"><b>Example</b></span><br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;">Temp Table<br /><br /> CREATE TABLE #Temp<br /> (<br /> UID int,<br /> FullName varchar(50),<br /> Addr varchar(150)<br /> )<br /> GO<br /> insert into #Temp values ( 1, 'Raj','Pune');<br /> GO<br /> Select * from #Temp<b> </b> </span></b></span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-29799437014532620092014-02-05T14:29:00.003+05:302014-02-05T14:35:35.439+05:30Dynamically Changing Master Pages<span style="font-family: "Trebuchet MS",sans-serif;">Suppose we have two Master pages and we want to change them dynamically.<br /><br />Let the style sheet are:</span><br />
<ol>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> blue.master - set background color to Blue</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> green.master </span><span style="font-family: "Trebuchet MS",sans-serif;">- set background color to Green</span></li>
</ol>
<span style="font-family: "Trebuchet MS",sans-serif;">I have added a page with a dropdownlist which list the master pages as option and in the code behind as drop down list selected index changed event response we saved the user selection in the session and in the Page_PreInit event we changed the master page dynamically. </span><br />
<a name='more'></a><br />
<b><span style="font-family: "Trebuchet MS",sans-serif;">Default1.aspx</span></b><br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;"><%@ Page Title="" Language="C#" MasterPageFile="~/blue.master" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default" %><br /><br /><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"><br /></asp:Content><br /><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><br /> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"><br /> <asp:ListItem Selected="True">Blue</asp:ListItem><br /> <asp:ListItem>Green</asp:ListItem><br /></asp:DropDownList><br /></asp:Content></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">Default1.aspx.cs</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Web;<br />using System.Web.UI;<br />using System.Web.UI.WebControls;<br /><br />public partial class Default1 : System.Web.UI.Page<br />{<br /><br /> <br /> protected void Page_PreInit(object sender, EventArgs e)<br /> {<br /> if (Session["bg"] != null)<br /> {<br /> switch (Session["bg"].ToString())<br /> {<br /> case "Green":<br /> MasterPageFile = "blue.master";<br /> break;<br /> case "Blue":<br /> MasterPageFile = "green.master";<br /> break;<br /> }<br /> }<br /> else<br /> {<br /> Session["bg"] = "Blue";<br /> }<br /> }<br /> protected void Page_Load(object sender, EventArgs e)<br /> {<br /><br /> }<br /> protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)<br /> {<br /> Session["bg"] = DropDownList1.SelectedValue;<br /> }<br />}</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"></span></b></span><br />
<span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-00Ta-89xuGE/UvH-Uci_WHI/AAAAAAAABg0/vJKTf5UbROw/s1600/tipsntricks.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-00Ta-89xuGE/UvH-Uci_WHI/AAAAAAAABg0/vJKTf5UbROw/s1600/tipsntricks.jpg" /></a>
<span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
</b></span></div>
<span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
</b></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">Here in the DropDownList1_SelectedIndexChanged I am assinging the selectedValue in a session variable.<br /><br />And in the Page_preInit I am changing the master page of the specific specific page.</span>Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-81301542769081878432014-02-04T17:09:00.000+05:302014-02-04T17:24:11.454+05:30AsyncPostBackTrigger vs PostBackTrigger with example<span style="font-family: "Trebuchet MS",sans-serif;">In the <triggers> template in an update panel, there are the options of an AsyncPostBackTrigger or a PostBackTrigger. By default, controls outside of an update panel will trigger a normal synchronous post back. The AsyncPostBackTrigger “wires” up these controls to trigger an asynchronous post back. Conversely, controls declared inside an update panel will trigger an asynchronous call by default. The PostBackTrigger short circuits this, and forces the control to do a synchronous post back. Utilizing a simple “time” example:</span><br />
<a name='more'></a><div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
<form id="form1?" runat="server"><br /> <asp:ScriptManager ID="ScriptManager1?" runat="server" /><br /> <div><br /> Page Generated @ <br /> <asp:Label runat="server" ID="uiPageTime" /><br /> <p /><br /> <asp:UpdatePanel runat="server" ID="update" UpdateMode="Conditional"><br /> <ContentTemplate><br /> <asp:Label runat="server" ID="uiTime" /><br /> <asp:Button runat="server" ID="uiInternalButton" Text="Click" /><br /> </ContentTemplate><br /> <Triggers><br /> <asp:AsyncPostBackTrigger ControlID="uiAsynch" EventName="click" /><br /> <asp:PostBackTrigger ControlID="uiInternalButton" /><br /> </Triggers><br /> </asp:UpdatePanel><br /> <asp:Button runat="server" ID="uiPostback" Text="Click" /><br /> <asp:Button runat="server" ID="uiAsynch" Text="Asynch" /><br /> </div><br /> </form><br />
</b></span></span></div>
And the code behind file. <br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
public partial class _Default : System.Web.UI.Page <br /> { <br /> protected void Page_Init(object sender, EventArgs e) <br /> { <br /> uiAsynch.Click += uiAsynch_Click; uiPostback.Click += uiPostback_Click; <br /> uiInternalButton.Click += uiInternalButton_Click; <br /> } <br /> protected void Page_Load(object sender, EventArgs e) <br /> { <br /> uiPageTime.Text = DateTime.Now.ToLongTimeString(); <br /> if (!IsPostBack) <br /> { <br /> uiTime.Text = DateTime.Now.ToLongTimeString(); <br /> } <br /> } <br /> private void uiInternalButton_Click(object sender, EventArgs e) <br /> { <br /> uiTime.Text = "Internal @ " + DateTime.Now.ToLongTimeString(); <br /> } <br /> private void uiPostback_Click(object sender, EventArgs e) <br /> { <br /> uiTime.Text = "Postback click @ " + DateTime.Now.ToLongTimeString(); <br /> update.Update(); <br /> } <br /> private void uiAsynch_Click(object sender, EventArgs e) <br /> { <br /> uiTime.Text = "Asych click @ " + DateTime.Now.ToLongTimeString(); <br /> update.Update(); <br /> } <br />}</b></span></span><br />
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-zj6wKztL_3A/UvDUl_qk5pI/AAAAAAAABgk/LNaSQwWmj1k/s1600/ajax.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-zj6wKztL_3A/UvDUl_qk5pI/AAAAAAAABgk/LNaSQwWmj1k/s1600/ajax.jpg" /></a></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-16116442879264388802014-01-31T10:54:00.000+05:302014-01-31T10:59:37.170+05:30ROW_NUMBER() in SQL<span style="font-family: "Trebuchet MS",sans-serif;">Hello guys,<br /><br />i have make a simple application which contains A Gridview with the thousend of records.<br />so i am manage it with paging.<br /><br />IF I WANT TO FILTER GRIDVIEW RECORDS WITH SQL ?<br /><br />So, i have take two textbox two filtering the gridview as follow.<br /><br />and i am sending the value in the database as follow.<br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
create table #tmp (id int,name varchar(10))<br /><br />insert into #tmp values(1,'a')</b></span></span><br /><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>insert into #tmp values(2,'b')</b></span></span></b></span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>insert into #tmp values(3,'c')</b></span></span></b></span></span></b></span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b><span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>insert into #tmp values(4,'d')</b></span></span> </b></span></span> </b></span></span><br /><br />select id,name,rownumber,totalrowcnt from<br />(<br /> select #tmp.*,ROW_NUMBER() over (order by #tmp.id) rownumber,count(*) over() totalrowcnt<br /> from #tmp<br />) result<br />where result.rownumber between <u>VALUE1</u> and <u>VALUE2</u><br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
* here value1 and value2 are textbox value.<br /><br />So, with this simple SQL query i can filter the gridview records.</span>Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-47356953309910878972014-01-22T10:35:00.003+05:302014-01-22T10:45:27.102+05:30Prevent self closing html tags in .NET<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">I create an input element, it will self close. How can I prevent this?</span><br />
<br />
<pre class="lang-cs prettyprint prettyprinted"><span style="font-family: "Trebuchet MS",sans-serif;"><code><span class="pun"><</span><span class="pln">asp</span><span class="pun">:</span><span class="typ">TextBox</span><span class="pln"> id</span><span class="pun">=</span><span class="str">"txt1"</span><span class="pln"> runat</span><span class="pun">=</span><span class="str">"server"</span><span class="pun">></</span><span class="pln">asp</span><span class="pun">:</span><span class="typ">TextBox</span><span class="pun"></span></code></span></pre>
<pre class="lang-cs prettyprint prettyprinted"><span style="font-family: "Trebuchet MS",sans-serif;"><b><code><span class="pun">SOLUTION</span></code></b></span></pre>
<ol>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Tools</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Options</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Text Editor</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">HTML</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Formatting</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;">Uncheck the box for <b>Auto insert close tag</b></span></li>
</ol>
<br />
<a name='more'></a><br /><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-ppJ4hhbUEnY/Ut9Qnh2nhOI/AAAAAAAABgU/0Xq1osAFlhk/s1600/a.bmp" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-ppJ4hhbUEnY/Ut9Qnh2nhOI/AAAAAAAABgU/0Xq1osAFlhk/s1600/a.bmp" /></a></div>
<b> </b><br />
<div>
<span style="font-family: "Trebuchet MS",sans-serif;">There are many other option for HTML formatting<b>.</b></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><b><br /></b></span>
<span style="font-family: "Trebuchet MS",sans-serif;">If you are using Visual Studio 2010, you can go to :</span>
<br />
<span style="font-family: "Trebuchet MS",sans-serif;">Tools > Options > Text Editor > HTML > Formatting > Tag Specific Options</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-QdruAhfGeyg/Ut9Qg-l_D5I/AAAAAAAABgI/jlf9S-zcAk0/s1600/b.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-QdruAhfGeyg/Ut9Qg-l_D5I/AAAAAAAABgI/jlf9S-zcAk0/s1600/b.JPG" /></a></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-67565633399956146972014-01-21T16:13:00.001+05:302014-01-21T16:14:40.458+05:30Set the tab order in VB.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">I have a bunch of buttons on a form and when the person presses TAB I want the focus of the controls move in a specific order.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;"><b>solution :</b></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">If you have form with lots of control then manage tab index by below method:</span><br />
<ul style="text-align: left;">
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Open form in design mode.</span></li>
<li><span style="font-family: "Trebuchet MS",sans-serif;"> Click on “View” from toolbar --> “Tab Order” at bottom.</span></li>
</ul>
<div style="text-align: left;">
<span style="font-family: "Trebuchet MS",sans-serif;"><br />Example:</span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-RL9PfkF-c4I/Ut5PiOsHphI/AAAAAAAABfw/MAstSLaPYx0/s1600/taborder.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-RL9PfkF-c4I/Ut5PiOsHphI/AAAAAAAABfw/MAstSLaPYx0/s1600/taborder.png" /></a></div>
<br /></div>
<div style="text-align: left;">
<span style="font-family: "Trebuchet MS",sans-serif;">Then just click on controls one by one in order that you want to set tab order.</span></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-10550466691728031082014-01-12T15:32:00.001+05:302014-01-12T15:32:25.932+05:30C# Event Handlers and Delegates in ASP.Net with Web User Controls<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">This article should help as a general how to on event handlers and delegates in C# as well as propose a different way to handle cross page methods in your ASP .Net website from a web user control or other page.<br /><br />Create event handlers and their delegates in the user control, fire them from the methods tied to the internal controls protected events, and define the methods that will handle the new events in the page (see code below).</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br />This article should help as a general how to on event handlers and delegates in C# as well as propose a different way to handle cross page methods in your ASP .Net website from a web user control or other page.</span><br />
<a name='more'></a><span style="font-family: "Trebuchet MS",sans-serif;"><br /><br />Dilemma:<br />Page contains user control which has some methods and functionality built in. When a particular button click or other generic event is fired in the user control, it needs to call back to the parent page.<br /><br />Solution:<br />Create event handlers and their delegates in the user control, fire them from the methods tied to the internal controls protected events, and define the methods that will handle the new events in the page (see code below).
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
C# (with some VB notes):<br /><br />//delegate declaration not necessary in VB<br />
public delegate void MyCustomHandler(object sender, EventArgs e);<br /> public event MyCustomHandler SomethingClicked;<br /> <br /> protected void btnButton1_Click(object sender, EventArgs e)<br /> {<br /> //tell our parent page which is listening for the event that something was clicked<br /> //this null check and method invoke is the equivalent of raise event in VB<br /> if (SomethingClicked != null)<br /> {<br /> SomethingClicked(sender, e);<br /> }<br /> <br /> //do some other work specific to this button in the user control<br /> }<br /><br />That’s the code for your user control, now for the page.<br /><br />protected void Page_Load(object sender, EventArgs e)<br /> {<br /> <br /> MyUserControl1.SomethingClicked += new MyUserControl1.MyCustomHandler(MyUserControl1_SomethingClicked);<br /> <br /> <br /> if (!Page.IsPostBack)<br /> {<br /> //do my other normal work<br /> }<br /> <br /> }<br /> <br /> protected void MyUserControl1_SomethingClicked(object sender, EventArgs e)<br /> {<br /> //voila! clicking on the button in your user control will fire this method on the parent page!<br /> }<br /><br />Alternatively instead of declaring your own delegate, you can also simply use:<br /><br />//in control<br /> public event EventHandler SomethingClicked;<br /> <br /> //and in page load<br /> MyUserControl1.SomethingClicked+= new EventHandler(MyUserControl1_SomethingClicked);
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
If you have no need for custom arguments, this a good quick alternative that may be well liked by VB users where delegate declaration is optional.</span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-91154177746919720952014-01-12T15:27:00.000+05:302014-01-12T15:28:11.069+05:30Polymorphisms in C++<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">When people talk about polymorphism in C++ they usually mean the thing of using a derived class through the base class pointer or reference, which is called subtype polymorphism. But they often forget that there are all kinds of other polymorphisms in C++, such as parametric polymorphism, ad-hoc polymorphism and coercion polymorphism.<br /><br />These polymorphisms also go by different names in C++,<br /><br />Subtype polymorphism is also known as runtime polymorphism.<br />Parametric polymorphism is also known as compile-time polymorphism.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">Ad-hoc polymorphism is also known as overloading. </span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">Coercion is also known as (implicit or explicit) casting.</span><br />
<a name='more'></a><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br />In this article I'll illustrate all the polymorphisms through examples in C++ language and also give insight on why they have various other names.<br /><br />Subtype Polymorphism (Runtime Polymorphism)<br />Subtype polymorphism is what everyone understands when they say "polymorphism" in C++. It's the ability to use derived classes through base class pointers and references.<br /><br />Here is an example. Suppose you have various cats like these felines,<br /><br />Since they are all of Felidae biological family, and they all should be able to meow, they can be represented as classes inheriting from Felid base class and overriding the meow pure virtual function,<br /><br />// file cats.h
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
class Felid {<br />public:<br /> virtual void meow() = 0;<br />};<br /><br />class Cat : public Felid {<br />public:<br /> void meow() { std::cout << "Meowing like a regular cat! meow!\n"; }<br />};<br /><br />class Tiger : public Felid {<br />public:<br /> void meow() { std::cout << "Meowing like a tiger! MREOWWW!\n"; }<br />};<br /><br />class Ocelot : public Felid {<br />public:<br /> void meow() { std::cout << "Meowing like an ocelot! mews!\n"; }<br />};<br /><br />Now the main program can use Cat, Tiger and Ocelot interchangeably through Felid (base class) pointer<br /><br />#include <iostream><br />#include "cats.h"<br /><br />void do_meowing(Felid *cat) {<br /> cat->meow();<br />}<br /><br />int main() {<br /> Cat cat;<br /> Tiger tiger;<br /> Ocelot ocelot;<br /><br /> do_meowing(&cat);<br /> do_meowing(&tiger);<br /> do_meowing(&ocelot);<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Here the main program passes pointers to cat, tiger and ocelot to do_meowing function that expects a pointer to Felid. Since they are all Felids, the program calls the right meow function for each felid and the output is:<br /><br />Meowing like a regular cat! meow!<br />Meowing like a tiger! MREOWWW!<br />Meowing like an ocelot! mews!<br /><br />Subtype polymorphism is also called runtime polymorphism for a good reason. The resolution of polymorphic function calls happens at runtime through an indirection via the virtual table. Another way of explaining this is that compiler does not locate the address of the function to be called at compile-time, instead when the program is run, the function is called by dereferencing the right pointer in the virtual table.<br /><br />In type theory it's also known as inclusion polymorphism.<br /><br />Parametric Polymorphism (Compile-Time Polymorphism)<br />Parametric polymorphism provides a means to execute the same code for any type. In C++ parametric polymorphism is implemented via templates.<br /><br />One of the simplest examples is a generic max function that finds maximum of two of its arguments,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
#include <iostream><br />#include <string><br /><br />template <class T><br />T max(T a, T b) {<br /> return a > b ? a : b;<br />}<br /><br />int main() {<br /> std::cout << ::max(9, 5) << std::endl; // 9<br /><br /> std::string foo("foo"), bar("bar");<br /> std::cout << ::max(foo, bar) << std::endl; // "foo"<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Here the max function is polymorphic on type T. Note, however, that it doesn't work on pointer types because comparing pointers compares the memory locations and not the contents. To get it working for pointers you'd have to specialize the template for pointer types and that would no longer be parametric polymorphism but would be ad-hoc polymorphism.<br /><br />Since parametric polymorphism happens at compile time, it's also called compile-time polymorphism.<br /><br />Ad-hoc Polymorphism (Overloading)<br />Ad-hoc polymorphism allows functions with the same name act differently for each type. For example, given two ints and the + operator, it adds them together. Given two std::strings it concatenates them together. This is called overloading.<br /><br />Here is a concrete example that implements function add for ints and strings,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
#include <iostream><br />#include <string><br /><br />int add(int a, int b) {<br /> return a + b;<br />}<br /><br />std::string add(const char *a, const char *b) {<br /> std::string result(a);<br /> result += b;<br /> return result;<br />}<br /><br />int main() {<br /> std::cout << add(5, 9) << std::endl;<br /> std::cout << add("hello ", "world") << std::endl;<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Ad-hoc polymorphism also appears in C++ if you specialize templates. Returning to the previous example about max function, here is how you'd write a max for two char *,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
template <><br />const char *max(const char *a, const char *b) {<br /> return strcmp(a, b) > 0 ? a : b;<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Now you can call ::max("foo", "bar") to find maximum of strings "foo" and "bar".<br /><br />Coercion Polymorphism (Casting)<br />Coercion happens when an object or a primitive is cast into another object type or primitive type. For example,<br /><br />float b = 6; // int gets promoted (cast) to float implicitly<br />int a = 9.99 // float gets demoted to int implicitly<br /><br />Explicit casting happens when you use C's type-casting expressions, such as (unsigned int *) or (int) or C++'s static_cast, const_cast, reinterpret_cast, or dynamic_cast.<br /><br />Coercion also happens if the constructor of a class isn't explicit, for example,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
#include <iostream><br /><br />class A {<br /> int foo;<br />public:<br /> A(int ffoo) : foo(ffoo) {}<br /> void giggidy() { std::cout << foo << std::endl; }<br />};<br /><br />void moo(A a) {<br /> a.giggidy();<br />}<br /><br />int main() {<br /> moo(55); // prints 55<br />}
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
If you made the constructor of A explicit, that would no longer be possible. It's always a good idea to make your constructors explicit to avoid accidental conversions.<br /><br />Also if a class defines conversion operator for type T, then it can be used anywhere where type T is expected.<br /><br />For example,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
class CrazyInt {<br /> int v;<br />public:<br /> CrazyInt(int i) : v(i) {}<br /> operator int() const { return v; } // conversion from CrazyInt to int<br />};
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
The CrazyInt defines a conversion operator to type int. Now if we had a function, let's say, print_int that took int as an argument, we could also pass it an object of type CrazyInt,
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
#include <iostream><br /><br />void print_int(int a) {<br /> std::cout << a << std::endl;<br />}<br /><br />int main() {<br /> CrazyInt b = 55;<br /> print_int(999); // prints 999<br /> print_int(b); // prints 55<br />}</b></span>
</span></div>
</div>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />Subtype polymorphism that I discussed earlier is actually also coercion polymorphism because the derived class gets converted into base class type.</span>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-2839291226628580982014-01-12T15:19:00.001+05:302014-01-12T15:19:14.660+05:30Creating dynamic textbox<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="prettyprint">
<span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"><b>ASPX</b><br /><br /><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %><br /><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><br /><html xmlns="http://www.w3.org/1999/xhtml" ><br /><br /><head runat="server"><br /><br /> <title>Untitled Page</title><br /><br /></head><br /><br /><body><br /><br /> <form id="form1" runat="server"><br /><br /> <div><br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add Textbox" /><br /><br /> <asp:Panel ID="Panel1" runat="server" ><br /><br /> <br /><br /> </asp:Panel> <br /><br /> </div><br /><br /> </form><br /><br /></body><br /><br /></html><br /><br /><br />C#<br /><br /><br />using System;<br /><br />using System.Web.UI.WebControls;<br /><br />using System.Collections.Generic;<br /><br />namespace WebApplication1<br /><br />{<br /><br /> public partial class _Default : System.Web.UI.Page<br /><br /> {<br /><br /> private List textboxes;<br /> protected void Page_Load(object sender, EventArgs e)<br /> {<br /> PreRender += new EventHandler(_Default_PreRender);<br /> textboxes = new List();<br /><br /> if(IsPostBack)<br /> {<br /> //recreate Textboxes<br /> int count = Int32.Parse(ViewState["tbCount"].ToString());<br /><br /> for (int i = 0; i < count; i++)<br /> {<br /> TextBox tb = new TextBox();<br /> tb.ID = "tb" + i;<br /> Panel1.Controls.Add(tb);<br /> textboxes.Add(tb);<br /> tb.Text = Request.Form[tb.ClientID];<br /> }<br /><br /> }<br /><br /> } <br /><br /> protected void Button1_Click(object sender, EventArgs e)<br /> {<br /> //create new textbox<br /><br /> TextBox tb = new TextBox();<br /> tb.ID = "tb" + textboxes.Count;<br /> Panel1.Controls.Add(tb);<br /> textboxes.Add(tb);<br /> }<br /><br /> void _Default_PreRender(object sender, EventArgs e)<br /> {<br /> //remember how many textboxes we had<br /> ViewState["tbCount"] = textboxes.Count;<br /> }<br /> }<br />}<br /> </span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">------------<br /><br />private System.Windows.Forms.TextBox[] textboxes;<br /><br />textboxes = new System.Windows.Forms.TextBox[2];<br /><br />int cnt=0;<br /><br />foreach (System.Windows.Forms.TextBox textbox in textboxes)<br />{<br /> // the location on the form. you may need to play with this<br /><br /> // and it should change for each textbox<br /><br /> textbox.Location = new System.Drawing.Point(88, 50); <br /><br /> textbox.Name = "textbox"+cnt.ToString();<br /><br /> textbox.Size = new System.Drawing.Size(173, 20);<br /><br /> textbox.TabIndex = cnt;<br /><br /> textbox.Visible = true; <br /><br /> cnt++;<br />}</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br />--------------<br /><br />public partial class AGEP : IdealFramework.UI.Screen<br />{</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">TextBox[] TB1 = new TextBox[18];<br /><br />public AGEP()<br />{<br />InitializeComponent();<br />}<br />private void AGEP_Load(object sender, EventArgs e)<br />{<br />int sub = 0;<br />int sub2 = 0;<br />while (sub < 18)<br />{<br />TB1[sub] = new TextBox();<br />sub2 = sub * 25 + 1;<br />TB1[0].Location = new Point(5, sub2);<br />pnlPmtArea.Container.Add(TB1[sub]);<br />sub++;<br />}<br />}</span>
</b></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-10749923274156729542014-01-12T15:11:00.002+05:302014-01-12T15:13:03.176+05:30Instantly Increase ASP.NET Scalability<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="font-family: "Trebuchet MS",sans-serif;">Each time a request for a .NET resource (.aspx, page, .ascx control, etc.) comes in a thread is grabbed from the available worker thread pool in the asp.net worker process (aspnet_wp.exe on IIS 5.x, w3wp.exe on IIS 6/7) and is assigned to a request. That thread is not released back into the thread pool until the final page has been rendered to the client and the request is complete.</span><br />
<a name='more'></a><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">Inside the ASP.Net Worker Process there are two thread pools. The worker thread pool handles all incoming requests and the I/O Thread pool handles the I/O (accessing the file system, web services and databases, etc.). But how many threads are there in these thread pools? I had assumed that the number of threads would vary from machine to machine – that ASP.NET and IIS would carefully balance the number of available threads against available hardware, but that is simply not the case. ASP.Net installs with a fixed, default number of threads to play with: The CLR for the 1.x Framework sets these defaults at just 20 worker threads and 20 I/O thread per CPU. Now this can be increased by modifying the machine.config, but if you are not aware of this, then 20 threads is all you’re playing with. If you have multiple sites sharing the same worker process, then they are all sharing this same thread pool.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">So long as the number of concurrent requests does not exceed the number of threads available in the pool, all is well. But when you are building enterprise level applications the thread pool can become depleted under heavy load, and remember by default heavy load is more than just 20 simultaneous requests. When this happens, new requests are entered into the request queue (and the users making the requests watch an hour glass spin). ASP.NET will allow the request queue to grow only so big before it starts to reject requests at which point it starts returning Error 503, Service Unavailable.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">If you are not aware of this “Glass Ceiling of Scalability”, this is a perplexing error – one that never happened in testing and may not reproducible in your test environment, as it only happens under extreme load.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">So the first thing you can do to improve scalability is to raise the values. The defaults for the ASP.NET 2.0 are 100 threads in each pool per CPU and the defaults for the ASP.NET 3.x CLR is 250 per CPU for worker threads and 1000 per CPU for I/O threads, however you can tune it further using the guidelines below. 32 bit windows can handle about 1400 concurrent threads, 64 bit windows can handle more, though I don’t have the figures.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">You can tune ASP.NET thread pool using maxWorkerThreads, minWorkerThreads, maxIoThreads, minFreeThreads, minLocalRequestFreeThreads and maxconnection attributes in your Machine.config file. Here are the default settings.</span>
<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
<system.net><br /><br /> <connectionManagement><br /><br /> <add address="*" maxconnection="2" /><br /><br /> </connectionManagement><br /><br /></system.net><br /><br /><system.web><br /><br /> <httpRuntime minFreeThreads="8" minLocalRequestFreeThreads="4" /><br /><br /> <processModel maxWorkerThreads="100" maxIoThreads="100" /><br /><br /></system.web>
</b></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">Here is the formula to reduce contention. Apply the recommended changes that are described below, across the settings and not in isolation.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;"> Configuration setting Default value (.NET Framework 1.1) Recommended value</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> maxconnection 2 12 * #CPUs</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> maxIoThreads 20 100</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> maxWorkerThreads 20 100</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> minFreeThreads 8 88 * #CPUs</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> minLocalRequestFreeThreads 4 76 * #CPUs</span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><b> Set maxconnection to 12 * # of CPUs</b>. This setting controls the maximum number of outgoing HTTP connections that you can initiate from a client. In this case, ASP.NET is the client. Set maxconnection to 12 * # of CPUs.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> <b>Set maxIoThreads to 100</b>. This setting controls the maximum number of I/O threads in the .NET thread pool. This number is automatically multiplied by the number of available CPUs. Set maxloThreads to 100.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> <b>Set maxWorkerThreads to 100</b>. This setting controls the maximum number of worker threads in the thread pool. This number is then automatically multiplied by the number of available CPUs. * Set maxWorkerThreads to 100.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> <b>Set minFreeThreads to 88 * # of CPUs</b>. This setting is used by the worker process to queue all the incoming requests if the number of available threads in the thread pool falls below the value for this setting. This setting effectively limits the number of requests that can run concurrently to maxWorkerThreads – minFreeThreads. Set minFreeThreads to 88 * # of CPUs. This limits the number of concurrent requests to 12 (assuming maxWorkerThreads is 100).</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"> <b>Set minLocalRequestFreeThreads to 76 * # of CPUs</b>. This setting is used by the worker process to queue requests from localhost (where a Web application sends requests to a local Web service) if the number of available threads in the thread pool falls below this number. This setting is similar to minFreeThreads but it only applies to localhost requests from the local computer. Set minLocalRequestFreeThreads to 76 * # of CPUs.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">Note The recommendations that are provided in this section are not rules. They are a starting point. Test to determine the appropriate settings for your scenario. If you move your application to a new computer, ensure that you recalculate and reconfigure the settings based on the number of CPUs in the new computer.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">By raising these values, you raise the “glass ceiling of scalability”, and in many cases that may be all you need to do, but what happens when you start getting more than 250 simultaneous requests? To make optimum use of the thread pool all IO requests that you know could take a second or more to process should be made asynchronously. More information on Asynchronous programming in ASP.NET is coming soon.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">I recommend testing your new machine.config locally or virtually somewhere first because if you make a mistake - for example you paste this in to the wrong area, or there is already a <system.web> element and you paste in a second one - ALL websites on the box will stop functioning as ASP.Net will not be able to parse the machine.config!!!</span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-12614852016341580182014-01-12T13:13:00.000+05:302014-01-12T13:19:17.054+05:30Performance Optmization with .NET<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">I have a web service, so the handler is called multiple times concurrently all the time.<br /><br />Inside I create SqlConnection and SqlCommand. I have to execute about 7 different commands. Different commands require various parameters, so I just add them once:
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
command.Parameters.Add(new SqlParameter("@UserID", userID));<br />command.Parameters.Add(new SqlParameter("@AppID", appID));<br />command.Parameters.Add(new SqlParameter("@SID", SIDInt));<br />command.Parameters.Add(new SqlParameter("@Day", timestamp.Date));<br />command.Parameters.Add(new SqlParameter("@TS", timestamp));
</b></span></span><br />
<a name='more'></a></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Then during execution I just change CommandText prorerty and then call ExecuteNonQuery(); or ExecuteScalar();<br /><br />And I face performance issue. For example little debuggin and profiling shows, that command<br /><br />command.CommandText = "SELECT LastShowTS FROM LogForAllTime WHERE UserID = @UserID";<br /><br />takes about 50ms in avarage. If I change it to:<br /><br />command.CommandText = "SELECT LastShowTS FROM LogForAllTime WHERE UserID = '" + userID.Replace("\'", "") + "'";<br /><br />then it takes only 1ms in avarage!<br /><br />That sounds like it has cached a query-plan for an atypical @UserID value (one of the early ones), and is reusing a poor plan for later queries. This isn't an issue in the second case since each has a separate plan. I suspect you just need to add:<br /><br />OPTION (OPTIMIZE FOR UNKNOWN)<br /><br />to the query, which will make it less keen to re-use plans blindly.<br /><br />Alternative theory:<br /><br />You might have a mismatch between the type of userID (in the C#) and the type of UserID (in the database). This could be as simple as unicode vs ANSI, or could be int vs varchar[n], etc. If in doubt, be very specific when configuring the parameter, to add it with the correct sub-type and size.<br />Clarification<br /><br />Indeed, it looks like the problem here is the difference between a C# string (unicode) and the database which is varchar(n) (ANSI). The SqlParameter should therefore be explicitly added as such (DbType.AnsiString).</span></div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-76588866840914547052014-01-12T13:03:00.002+05:302014-01-12T13:19:39.934+05:30How to connect to an external SQL server database in ASP.NET / VB.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">Connecting to databases in .NET is different if you are coming from other languages such as PHP. To connect to a database in ASP.NET / .NET in general, you use "Connection Strings" that essentially is the connection information to the database.<br /><br />First and foremost, in your code behind file within an ASP.NET application (or simply the .vb or .cs file of your .NET desktop application), you will need to first import the namespace that has the relevant database-related classes and methods, etc.<br /><br />Note: All examples use the Visual Basic language, but the concept is the same for both Visual Basic and C#, for example.</span><br />
<a name='more'></a><span style="font-family: "Trebuchet MS",sans-serif;"><br /><br />Code:<br /><br />Imports System.Data.SqlClient<br /><br />For ASP.NET applications, you have a Web.config file with every project or application you create, which is the main configuration file of an ASP.NET application (see this). The file itself is simply made up of recognised XML markup. You can have the connection string in the Web.config file if you wish, and then reference that in your appliction code:<br /><br />Web.config:<br />Code:<br />
</span>
<br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
<configuration><br /> <connectionStrings><br /> <add name="ApplicationServices"<br /> connectionString="Server=example.com;Initial Catalog=the_database;UID=the_user_of_db;Password=pw_here"<br /> providerName="System.Data.SqlClient" /><br /> </connectionStrings><br /></configuration><br />
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
In the application code, I made a class-level variable which gets the connection string from the Web.config file:<br /><br />Code:
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
Dim ConnectionStringReference = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
</b></span></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">
Note: "ApplicationServices" is my specific ConnectionString name, but you can actually call it whatever you like.<br /><br />Now, in whatever method you wish to execute queries, etc., you first connect to the database and then execute the query:<br /><br />Code:
<div class="prettyprint">
<span style="color: #444444;"><b>
Try<br /> Dim FetchSubRows As New SqlConnection(ConnectionStringReference) 'the class-level variable ConnectionString<br /><br /> FetchSubRows.Open() 'opens the connection<br /><br /> Dim FetchQuery As String = "SELECT Submission_ID, Submission_Title, Submission_Body, Submission_IP, Submission_Date FROM Submissions ORDER BY Submission_ID DESC" 'the SQL string<br /> Dim ExecuteCommand As New SqlCommand(FetchQuery, FetchSubRows) 'execute the query<br /> Dim DataReader As SqlDataReader = ExecuteCommand.ExecuteReader() 'we want to "read" the information, since it is a SELECT statement above<br /><br /> While DataReader.Read() 'the Read() method advances to the next applicable record of fetched data...so it will continue looping until all has been returned, essentially<br /> Return DataReader<br /> End While<br /><br /> If DataReader.HasRows = False Then 'has it got any actual rows?<br /> FetchSubmissionsError = 0<br /> End If<br /> Catch ex As SqlException 'if there was an error, perhaps with the SQL statement itself, catch this error and put it in a variable to be displayed elsewhere<br /> FetchSubmissionsError = -1<br /> FetchSubmissionsErrorMessage = ex.Message
<br /> End Try</b></span>
</div>
</span></div>
<span style="font-family: "Trebuchet MS",sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">I just want to point out the Try...Catch block is actually optional. It's simply a way in which you can handle unexpected errors that may occur in that code. In that code, the most obvious error that could occur is an error caused by the SQL query, hence it will catch all SqlException errors (SqlException being a class) and put that object in the ex variable. More information can be found on Exception Handlers here: What are object oriented exceptions / exception handlers - How do I use them? (this examples uses the PHP programming language as an example, but conceptually applies the same). You can also read the MSDN resource on Try...Catch...Finally statements on the MSDN (Microsoft Developer Network): Try...Catch...Finally Statement (Visual Basic)</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">Regarding the connection string</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><br /></span>
<span style="font-family: "Trebuchet MS",sans-serif;">Yes, you will need a connection string obviously. If you want to include this directly in your code, here is an example:</span><br />
<br />
Code:<br />
<div class="prettyprint">
<span style="color: #444444;"><b>
Try<br />
Dim FetchSubRows As New SqlConnection("Server=example.com;Initial Catalog=the_database;UID=the_user_of_db;Password=pw_here") ' << visible change is this<br /> FetchSubRows.Open() 'opens the connection<br /><br /> Dim FetchQuery As String = "SELECT Submission_ID, Submission_Title, Submission_Body, Submission_IP, Submission_Date FROM Submissions ORDER BY Submission_ID DESC" 'the SQL string<br /> Dim ExecuteCommand As New SqlCommand(FetchQuery, FetchSubRows) 'execute the query<br /> Dim DataReader As SqlDataReader = ExecuteCommand.ExecuteReader() 'we want to "read" the information, since it is a SELECT statement above<br /><br /> While DataReader.Read() 'the Read() method advances to the next applicable record of fetched data...so it will continue looping until all has been returned, essentially<br /> Return DataReader<br /> End While<br /><br /> If DataReader.HasRows = False Then 'has it got any actual rows?<br /> FetchSubmissionsError = 0<br /> End If<br /> Catch ex As SqlException 'if there was an error, perhaps with the SQL statement itself, catch this error and put it in a variable to be displayed elsewhere<br /> FetchSubmissionsError = -1<br /> FetchSubmissionsErrorMessage = ex.Message<br /> End Try</b></span></div>
<span style="font-family: "Trebuchet MS",sans-serif;">So now you understand how to connect to external databases, this means when you are creating a local project on your machine, you can connect to an external database that may be hosted on your external Windows Server or Windows Hosting environment. You do not need to rely on a local database on your machine.</span>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-89255805161293370682014-01-11T15:10:00.001+05:302014-01-11T15:15:24.802+05:30DateTimePicker ValueChanged and CloseUp Event<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">some time ago i come to know this problem in my form When the month forward or backward arrow is clicked on my DateTimePicker control it repeatedly fires the ValueChanged event.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;">I have solve this problem using Closeup event of DatepTimePicker<br /><br /><b>ValueChanged Event</b><br /><br />DateTimePicker ValueChanged Event repeats with month/year arrow<br /><br /><u>VB.NET</u><br /><br />
</span><br />
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;">
<span style="color: #444444;"><b>
Private Sub datepicker_ValueChanged (sender As Object,e As EventArgs) Handels datepicker.ValueChanged </b></span>
<span style="font-family: "Trebuchet MS",sans-serif;"></span>
MessageBox.Show("You are in the DateTimePicker.ValueChanged event.")</span>
</div>
</div>
</div>
<br />
<span style="font-family: "Trebuchet MS",sans-serif;">
<b>CloseUp Event</b><br /><br />
</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">
when the user changes the value manually, the CloseUp event obviously isn't triggered<br /><br /><u>VB.NET</u>
<div class="prettyprint">
<span style="color: #444444;"><b>
Private Sub datepicker_CloseUp(sender As Object,e As EventArgs) Handels datepicker.CloseUp<br /></b></span><br />MessageBox.Show("You are in the DateTimePicker.CloseUp event.")</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-1334563343962614502013-12-19T13:50:00.000+05:302013-12-19T13:53:09.243+05:30How to display a button on page after a period of time in ASP.NET?<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"><html><br /><head><br /><script type="text/javascript"><br /><br /> function showButton()<br /> {<br /> document.getElementById("btnContinue").style.visibility = "visible";<br /> }<br /><br /> function hideButton()<br /> {<br /> document.getElementById("btnContinue").style.visibility = "hidden";<br /> }<br /><br /> window.onload = function()<br /> {<br /> hideButton();<br /> setTimeout('showButton()', 12000);<br /> }<br /><br /> </script><br /><br /></head><br /><body><br /><input type="button" id="btnContinue" value="Continue" /><br /></body><br /></html></span>
</b></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0tag:blogger.com,1999:blog-3283360236115652002.post-53538909743760856162013-12-19T13:41:00.002+05:302013-12-19T13:45:21.004+05:30How to send an image with this customized C# Mail function?<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
<span style="font-family: "Trebuchet MS",sans-serif;">C# Mail Function:</span></h3>
<span style="font-family: "Trebuchet MS",sans-serif;"> /*For sending an email notification to the new user*/</span>
<div class="prettyprint">
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="color: #444444;"><b>
<span style="font-family: "Trebuchet MS",sans-serif;"> protected void SendNotificationByEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)<br /> {<br /> SmtpClient sc = new SmtpClient("MailServer");<br /> try<br /> {<br /> MailMessage msg = new MailMessage();<br /> msg.From = new MailAddress("Test@MailServer.com", "Test System)");<br /><br /><br /> msg.Bcc.Add(toAddresses);<br /> msg.Subject = MailSubject;<br /> msg.Body = MessageBody;<br /> msg.IsBodyHtml = isBodyHtml;<br /> sc.Send(msg);<br /> }<br /> catch (Exception ex)<br /> {<br /> throw ex;<br /> }<br /><br /> }<br /><br /> protected void Send(string username)<br /> {<br /> string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=TestDB;Integrated Security=True";<br /><br /> string networkID = username.ToString();<br /> using (SqlConnection conn = new SqlConnection(connString))<br /> {<br /> var sbEmailAddresses = new System.Text.StringBuilder(2000);<br /><br /> //initiate the varibles <br /> string name = null;<br /><br /> // Open DB connection.<br /> conn.Open();<br /><br /> string cmdText2 = @"SELECT Name<br /> FROM dbo.employee<br /> WHERE (Username = @networkID)";<br /> using (SqlCommand cmd = new SqlCommand(cmdText2, conn))<br /> {<br /> cmd.Parameters.AddWithValue("@networkID", networkID);<br /> SqlDataReader reader = cmd.ExecuteReader();<br /> if (reader != null)<br /> {<br /> if (reader.Read())<br /> {<br /> name = reader["Name"].ToString();<br /> sbEmailAddresses.Append(username).Append("@mailServer.com");<br /> }<br /> }<br /><br /> //var sEMailAddresses = sbEmailAddresses.ToString();<br /> string body = @"Good day "<br /> + name +<br /> @", <br /><br /><br /> You have been added to the <a href='http://localhost/TestSys'>Test</a>. <br /> <br /><br /><br />resources. <br /> </b> <br /> <br /><br /> <img src='images/Admin/EmailNotification.jpg' alt=' Message'/><br /><br /> string imagePath = Server.MapPath("~") + "\\";<br /> string fileName = imagePath + "EmailNotification.jpg";<br /> AlternateView av = AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html)<br /> LinkedResource linkedRes = new LinkedResource(fileName);<br /> linkedRes.ContentId = "image1";<br /> linkedRes.ContentType.Name = fileName;<br /> av.LinkedResources.Add(linkedRes);<br /><br /><br /> SendNotificationByEmail(sbEmailAddresses.ToString(), "", "Welcome", body, true);<br /> sbEmailAddresses.Clear();<br /> reader.Close();<br /> }<br /><br /> conn.Close();<br /> }<br />} </span></b></span></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/04882404158649144750noreply@blogger.com0