Mail ,GetBodyAsHtml,GetToList from Db
Private Function GetBodyAsHtml(ByVal Bodytext As String, ByVal HeaderText As String, ByVal FooterText As String) As String
Dim sb = New System.Text.StringBuilder
sb.Append(“Tasks”)
sb.Append(“
| “) sb.Append(“
“) Return sb.ToString Try cmdSelect.Connection = _sqlConnection cmdSelect.CommandText = “Select Name=MemEmail from Member1 where id= ‘” & Strid & “‘” da = New SqlDataAdapter(cmdSelect) For Each row As DataRow In ds.Tables(“Tasks”).Rows ’sends Mail Dim strPath As String = “” Try ‘getting body for mail Arrtoid = Split(ToId, “,”) If Trim(FromId) “” Then NewMessage.From = New MailAddress(FromId) For Each strT In Arrtoid NewMessage.Subject = Subject If Trim(AttachmentPath) “” Then NewMessage.IsBodyHtml = True Catch ex As Exception End Function ========================================================================= Convert Datatable To Html File,SaveAsHtmlFile (ByVal renderedOutput As StringBuilderPrivate Function ConvertToHtmlFile(ByVal sentDataTable As DataTable) As String ‘ Check if the Sent DataTable is not empty or a Null ‘Get a worker object. ‘Open tags and write the top portion.
“) Return SaveAsHtmlFile(HtmlStringBuilder) HtmlStringBuilder = Nothing End Function Private Function SaveAsHtmlFile(ByVal renderedOutput As StringBuilder) As String desktop application Application.StartupPath & “..\..\..\Images”Dim path As String = Application.StartupPath & “..\..\..\Images” Date validations in a text box…javascript<html xmlns=”http://www.w3.org/1999/xhtml“> function isInteger(s){ function stripCharsInBag(s, bag){ function daysInFebruary (year){ function isDate(dtStr){ function ValidateForm(){ Service-Oriented Architecture
Viewstate Session CacheViewstate is used to store Value for the current page only.
Session saves Value till the Browser is not closed.
Cache also stored the Value till the Browser exist but when the System resouce goes low then the items in the Cache are dropped directly. SESSION Variables are stored on the server, can hold any type of data including references, they are similar to global variables in a windows application and use HTTP cookies to store a key with which to locate user’s session variables.
VIEWSTATE Variables are stored in the browser (not as cookies) but in a hidden field in the browser. Also Viewstate can hold only string data or serializable objects. The viewstate data will be sent twice over the internet (from server to browser, and back), so you will want to keep that as small as possible. Plus, viewstate will only work in postback-scenarios, you will lose it if you redirect or you supply the user with a regular link to some page of yours (but this might be exactly what you want)
On the other hand, if you store lots of data for lots of sessions, you need a lot of memory on your server. Plus session-state management itself costs some time on the server.
I don’t think it is possible to give a hard formula whether to use viewstate or sessionstate, but if you really don’t need sessions, you might investigate a session-less site (<sessionState mode=”off”/> in web.config) using viewstate to keep some state.
Session: Memory space used to persist user-specific data on the server side.One Session created per user per Session. ViewState: Hidden form field in ASP.Net form, used to persist page-instance-specific data. State: A generic term for persistence of data
Caching It’s performance-related. We can store data in local memory through caching for data serving from memory directly for incoming requests. Output Caching (Page Level Caching) To solve the problem, We can specify explicitly, like VaryByParam=”PartNo”, or by saying to vary on all GET/POST parameters, like: VaryByParam=”*”. Cache["foo"] = bar; note, the cache value should not null prior to doing something with the data. DataSet GetUserInfoFromDatabase() Session State Management Session State Management On behalf of clients it’s keep maintaining state for track of items. It’s very much useful in online shopping cart. InProc: OutProc : Note : SQL Server : Stored proc (xmldoc XML) calling methodsPublic Function CreateXml() As String Dim xml As New StringBuilder() Try xml.Append(“<root><Tasks TasksId=”"”) xml.Append(TasksId)
xml.Append(“”" Name=”"”) xml.Append(Name)
xml.Append(“”" Priority=”"”) xml.Append(Priority)
xml.Append(“”" IsNotificationOnly=”"”) xml.Append(IsNotificationOnly)
xml.Append(“”" IsRetain=”"”) xml.Append(IsRetain)
xml.Append(“”" EngagementID=”"”) xml.Append(EngagementID)
xml.Append(“”" Assignor=”"”) xml.Append(Assignor)
xml.Append(“”" AssignedDate=”"”) xml.Append(AssignedDate)
xml.Append(“”" Desc=”"”) xml.Append(Desc)
xml.Append(“”" DueDate=”"”) xml.Append(DueDate)
xml.Append(“”" HasIssues=”"”) xml.Append(HasIssues)
xml.Append(“”" HasAttachment=”"”) xml.Append(HasAttachment)
xml.Append(“”" Requester=”"”) xml.Append(Requester)
xml.Append(“”" HasServiceExtension=”"”) xml.Append(HasServiceExtension)
xml.Append(“”" ReviewStatus=”"”) xml.Append(ReviewStatus)
xml.Append(“”" ImportSrc=”"”) xml.Append(ImportSrc)
xml.Append(“”" ImportSourceInfo=”"”) xml.Append(ImportSourceInfo)
xml.Append(“”" ImportSourceItem=”"”) xml.Append(ImportSourceItem)
xml.Append(“”" ImportSourceVersion=”"”) xml.Append(ImportSourceVersion)
xml.Append(“”" ImportSourceType=”"”) xml.Append(ImportSourceType)
xml.Append(“”" CreatedBy=”"”) xml.Append(CreatedBy)
xml.Append(“”" CreatedOn=”"”) xml.Append(CreatedOn)
xml.Append(“”" rowguid=”"”) xml.Append(rowguid)
xml.Append(“”"/></root>”) Return (xml.ToString()) Catch err As Exception Throw err End Try End Function
Public Function saveTask(ByVal xmlTasks As String, ByVal StrTaskid As String) As Boolean
Dim _sqlConnection As New SqlConnection() Dim cmdInsert As New SqlCommand() Dim retVal As Boolean
Dim strConn As String = ConfigurationManager.ConnectionStrings(“sqlConnectionString”).ToString()
Try _sqlConnection.ConnectionString = strConn _sqlConnection.Open()
cmdInsert.Connection = _sqlConnection cmdInsert.CommandType = CommandType.StoredProcedure
cmdInsert.CommandText = “Proc_SaveTask”
cmdInsert.Parameters.Add(“@xmldoc”, SqlDbType.Xml) cmdInsert.Parameters(0).Value = xmlTasks
cmdInsert.Parameters.Add(“@Id”, SqlDbType.VarChar) cmdInsert.Parameters(1).Value = StrTaskid
cmdInsert.ExecuteNonQuery()
retVal = True
Catch ex As Exception
retVal = False
End Try
Return retVal
End Function
=============================================== set ANSI_NULLS ON AS BEGIN TRAN –Create an internal representation of the XML document. INSERT INTO Task (TasksId,[Name], Priority,IsNotificationOnly,IsRetain, SELECT ——————————————————————————- AS ——————————————————————————- javascript validations radiobutton list etc…..(full page)<html xmlns=”http://www.w3.org/1999/xhtml”> <head runat=”server”> <title>Untitled Page</title> <script type=”text/javascript”> function ValidateNumbers() { if(document.getElementById(‘txtNumber’).value!=”) { var input= document.getElementById(‘txtNumber’).value;
// var testName =/^([0-9])*$/; // if(!testName.test(input)) // { // alert(“Enter only numeric values”); // return false; // } if (input == null || !input.toString().match(/^[-]?\d*\.?\d*$/)) { alert(“Enter only numeric values”); return false; }
} if(document.getElementById(‘ddlInput’).selectedIndex == 0) { alert(“Select Numbers”); return false; } //validate radio list var listItemArray = document.getElementsByName(‘ddlColors’); var isItemChecked = false;
for (var i=0; i<listItemArray.length; i++) { var listItem = listItemArray[i];
if ( listItem.checked ) { //alert(listItem.value); isItemChecked = true; } }
if ( isItemChecked == false ) { alert(‘Nothing is checked!’);
return false; }
} </script> </head> <body> <form id=”form1″ runat=”server”> <div>
<asp:TextBox ID=”txtNumber” runat=”server”></asp:TextBox> <asp:DropDownList ID=”ddlInput” runat=”server”> <asp:ListItem Text=”Select”></asp:ListItem> <asp:ListItem Text=”One”></asp:ListItem> <asp:ListItem Text=”Two”></asp:ListItem> <asp:ListItem Text=”Three”></asp:ListItem> </asp:DropDownList> <asp:RadioButtonList ID=”ddlColors” runat=”server”> <asp:ListItem Text=”Red”></asp:ListItem> <asp:ListItem Text=”Blue”></asp:ListItem> <asp:ListItem Text=”White”></asp:ListItem> </asp:RadioButtonList> <asp:Button ID=”btnSubmit” runat=”server” OnClientClick=”return ValidateNumbers()” Text=”Submit” /> </div> </form> </body> </html>
javascripts -1<script language=”javascript” type=”text/javascript”>
//the following function is currently not used
function reSize() { var winW = 630, winH = 460;
if (parseInt(navigator.appVersion)>3) { if (navigator.appName==“Netscape”) { winW = window.innerWidth; winH = window.innerHeight; } if (navigator.appName.indexOf(“Microsoft”)!=-1) { winW = document.body.offsetWidth; winH = document.body.offsetHeight; } }
alert(winH); winH = winH – 90; var windowheight = window.screen.height; var objMenu = document.getElementById(“CategoryMenu_tblMenuControl”); var objHeader = document.getElementById(“tbHeader”); //objMenu.height = winH + “px” }
//The following ConfirmDialog function is used in MultiLocation grid events function ConfirmDialog() { var obj = document.getElementById(“MultiLocation1_pnlMulti”); if (obj.disabled == false) { return confirm(‘Are you sure you want to delete this record’); } }
var dtpSdate;
function GetDateName(strName) { var obj = document.getElementById(‘Engpanel1_Dtp’+ strName +‘_MyDtpText’); dtpSdate=‘Engpanel1_Dtp’+ strName +‘_MyDtpText’; if(obj == null) { obj = document.getElementById(‘Engpanel1_txt’+strName); if(obj != null) { dtpSdate=‘Engpanel1_txt’+strName; } } return dtpSdate; }
function showAlert(msg) { alert(msg); return false; }
function Validate(ctrl,msg) { var obj = document.getElementById(ctrl);
if(obj != null) { if(obj.value == ”) { showAlert(msg); return false; } } } function checkObjExsist(ctrl) { var obj = document.getElementById(ctrl); if(obj == null) { return false; } } function DateNullCheck() {
if (Validate( GetDateName(‘Periodstartdate’) ,‘Period Start Date should not be empty’)== false ) { return false ; } if (Validate(GetDateName(‘Periodenddate’),‘Period End Date should not be empty’)== false ) { return false ; } if (Validate(GetDateName(‘Expectedreportingdate’),‘Reporting date should not be empty’)== false ) { return false ; } return true; }
function ValidateDateControls() {
if (Validate(‘Engpanel1_txtClientname’,‘Client Name should not be empty’)== false && checkObjExsist(‘Engpanel1_txtClientname’)!=false) { return false ; }
if (Validate(‘Engpanel1_txtEngagementname’,‘Engagement Name should not be empty’)== false ) { return false ; }
if(checkObjExsist(‘Engpanel1_txtSentinelnumber’)!= false) { var input= document.getElementById(‘Engpanel1_txtSentinelnumber’).value;
var testName =/^([0-9])*$/;
if (Validate(‘Engpanel1_txtSentinelnumber’,‘Sentinel Number should not be empty’)== false ) { return false ; }
if(!testName.test(input)) { showAlert(“Digits Only Allowed in Sentinel number”); return false; } }
if(checkObjExsist(‘Engpanel1_txtEngagementnumber’)!= false) { var input= document.getElementById(‘Engpanel1_txtEngagementnumber’).value;
var testName =/^([0-9])*$/;
if (Validate(‘Engpanel1_txtEngagementnumber’,‘Engagement Number should not be empty’)== false ) { return false ; }
if(!testName.test(input)) { showAlert(“Digits Only Allowed in Engagement number”); return false; } }
if ((checkObjExsist(GetDateName(‘Periodstartdate’))!= false && checkObjExsist(GetDateName(‘Periodenddate’))!= false && checkObjExsist(GetDateName(‘Expectedreportingdate’))!= false)) { if (DateNullCheck()==false) { return false; }
if( document.getElementById(GetDateName(‘Periodstartdate’)).value !=” && document.getElementById(GetDateName(‘Periodenddate’)).value!=” && document.getElementById(GetDateName(‘Expectedreportingdate’)).value!=”) { if( Date.parse(document.getElementById(GetDateName(‘Periodstartdate’)).value)> Date.parse(document.getElementById(GetDateName(‘Periodenddate’)).value)) { showAlert(“End Date should not be less than Start Date”); return false; } if ( Date.parse(document.getElementById(GetDateName(‘Expectedreportingdate’)).value)>Date.parse(document.getElementById(GetDateName(‘Periodenddate’)).value)) { showAlert(‘Expected Reporting Date should not be greater than Period End Date’); return false; } if (Date.parse(document.getElementById(GetDateName(‘Periodstartdate’)).value)> Date.parse(document.getElementById(GetDateName(‘Expectedreportingdate’)).value)) { showAlert(‘Expected Reporting date should not be less than Period Start Date’); return false; } } else { return false; } }//Datenullcheck
if(checkObjExsist(‘Engpanel1_DrpInwhichcountryistheengagementbeingperformed?’)!= false && document.getElementById(‘Engpanel1_DrpInwhichcountryistheengagementbeingperformed?’).selectedIndex == 0 ) { showAlert(“Select in Which Country is the engagement being performed”); return false; } } </script>
|