Microsoft .NET Framework is a software component that is a part of Microsoft Windows operating systems. It has a large library of pre-coded solutions to common program requirements, and manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering, and is intended to be used by most new applications created for the Windows platform.
The pre-coded solutions that form the framework's Base Class Library cover a large range of programming needs in areas including: user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. The class library is used by programmers who combine it with their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that manages the program's runtime requirements. This runtime environment, which is also a part of the .NET Framework, is known as the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine, so that programmers need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other important services such as security mechanisms, memory management, and exception handling. The class library and the CLR together compose the .NET Framework.
(1)Display outlook express using asp.net
strmail ="ramkumar"
lblHeader.Text &= "<a href='mailto:" & strmail & "'>" & strmail "</a>" & " at " & strmail
(2)Tab in alert msg
msg = "\tYour request will not be completed at this time\r\n"
msg &= "\tContact user\r\n" & "\t"
(3)Pass querystring value using hyperlink control
<hyperlink DataNavigateUrlFormatString="javascript:void(window.open('sample.aspx?RowIdent={0}',null,'width=1000,height=435,left=0,top=45'));">
(4)Display word/pdf in browser
Response.ContentType = datareader.Item(1) like word/xml
response.binarywrite(datareader.item(2))
(5)Display popup using anchor link
<A title="click here to view Codes" onclick="window.open('EHS_frmUniformFireCodeLookup.aspx','EHS_frmUniformFireCodeLookup','width=1000,height=535,left=0,top=25,scrollbar=yes')"
href="javascript:;">(Secondary):</A>
(6)focus on the textbox
Me.RegisterStartupScript("SetFocus", "<script>document.getElementById('" &textbox.ClientID & "').focus();</script>")
(7)display the barcode in Label with special chars and datafield
<asp:Label id="lblPartNumberBarCode" runat="server">
<font face="3 of 9 Barcode" size="5">
<%# "*" & Trim(Container.DataItem("part_number")) & "*" %>
</font> </asp:Label>
(8)validate control in Datagrid in serverside in any event
Dim dgItem As DataGridItem
For Each dgItem In dgHistory.Items
Dim txt1 As TextBox = CType(dgItem.FindControl("txt1"), TextBox)
Dim txt2 As TextBox = CType(dgItem.FindControl("txt2"), TextBox)
If txt1.Text <> String.Empty And txt2.Text <> String.Empty Then
abool=true
End If
Next
(9)Passing values from parent to child using datagrid
Parent
******
<A href="javascript:OpenWindow('dd2.aspx?textbox=textbox1','sample',280,250,205,650);" style="OVERFLOW: auto"><IMG src="./images/open.ico" border="0">
</A>
Child
*****
dd2.aspx
********
<ItemTemplate> (Cell 0)
<asp:LinkButton ID="lbSelect" text="Select" CommandName="Edit" CausesValidation="False" Runat="server"></asp:LinkButton></ItemTemplate>
<ItemTemplate> (Cell 1)
<asp:Literal ID="lbSelect" text="Prasanna" " CausesValidation="False" Runat="server"></asp:Literal></ItemTemplate>
control.Value = Request.QueryString("textbox").ToString()
Private Sub dgSample_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgSample.EditCommand
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
Dim a As String = e.Item.Cells(1).Text
strScript += System.Convert.ToString(e.Item.Cells(1).Text)
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
End Sub
(10)Clear values using javascript
<INPUT class="button" id="btnClear" onclick="document.location.href='Dock_Received_Detail_NotDone.aspx';" type="button" value="Reset">
(11)passing values to popup window using code behind javascript
button_click()
RegisterStartupScript("focus", "<script language=""javascript"">" & vbCrLf & _
vbTab & "var win=window.open('ManifestReport.aspx?flag=" & 0 & "&date1=" & temp &"',null,'left=0px,height=700px,width=800px,scrollbars=1','true');" & _
vbCrLf & "<" & "/script>")
end sub
(12)display confirm msg box using data field in datagrid
btnclick.Attributes("onclick") = "javascript:return confirm('temp- " & Trim(DataBinder.Eval(e.Item.DataItem, "sno")) & "?')"
(13)Showmodal dialog
var Args = new Array(strUserID, strUserFullName);
var WinSettings = "center:yes;resizable:no;dialogHeight:250px;dialogWidth:390px"
var Args2 = window.showModalDialog("PopUp.aspx", Args, WinSettings);
(14)Close popup window using javascript
<INPUT class="button" id="Button1" accessKey="c" onclick="javascript:self.close();" type="button"
value="Close" name="btnClose" runat="server">
(15)Validate special character using javascript like -,+, %,&, etc
function SplValidate()
{
var ValidChars = "!@#$%-+=.',/*\&";
var Char;
if (document.getElementById("txtLinePosition").value!="")
{
for (var i = 0; i<= document.getElementById("txtvalue").value.length-1; i++)
{
Char = document.getElementById("txtLinePosition").value.charAt(i);
if (ValidChars.indexOf(Char) != -1)
{
document.getElementById("txtLinePosition").value ='';
document.getElementById("txtLinePosition").focus();
return false;
}
}
}
(16)Install assembly into gac
ref: http://support.microsoft.com/kb/315682
Location :C:\WINDOWS\assembly
fIRT create strong name then install assembly(dll) into gac.
Open dotnet command prompt.
(ex)
E:\Prasanna\Dotnet code\TempExportReport\bin>gacutil /i TempExportReport.dll
Adding ur assembly into machine.config
***********************************
C:\WINDOWS\Microsoft.NET\Framework\v1.0.2914\CONFIG\machine.config
<add assembly="AssemblyFileName, Version=x.x.x.x, Culture=neutral, PublicKeyToken=xxxxxxxxx" />
(17)Uninstall the assembly from gac
********************************
Open dotnet command prompt.
(ex) C:\WINDOWS\assembly>gacutil.exe -u TempExportReport
Tempexportreport is the one of the assembly.
Incase u have the same assembly with different version, like tempexportreport 1.0, tempexportreport 1.1 then using the following command
(ex) C:\WINDOWS\assembly>gacutil.exe -u TempExportReport1.0
(18)refresh page using javascript in codebehind
RegisterStartupScript("message", "<script language=""javascript"">" & vbCrLf & _
vbTab & "alert('deleted successfully.'); document.location.href='sample.aspx';" & _vbCrLf & "<" & "/script>")
(19)Generate data using javascript
function createDate()
{
var d = new Date();
var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var t_date = new String();
t_date = d.getDate() + '';
if (t_date.length == 1)
{
t_date = '0' + t_date;
}
var t_mon = d.getMonth();
var t_year = d.getFullYear();
alert(t_date + "-" + m_names[t_mon] + "-" + t_year);
}
(20)ItemDatabound event
Private Sub dgrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgrid.ItemDataBound
If DataBinder.Eval(e.Item.DataItem, "sex") = "M" Then
lblMark.BackColor = System.Drawing.Color.Red
End If
end sub
(21)Display price (or) Cost using asp.net
lblPrice.Text = Format$(Val(DataBinder.Eval(e.Item.DataItem, "prices")), "#########0.00")
(22)Custom sorting in datagrid
Dim SortExpression As String = grid.Attributes("SortExpression")
Dim SortDirection As String = grid.Attributes("SortDirection")
grid.Sort = SortExpression + " " + SortDirection
grid.DataSource = grid
grid.DataBind()
(23)New line in alert msgbox.
alert("\t1.Purchase Order #\r\n" & "\t2.Receiver\r\n" & "\t3.Part #\r\n" & "\t4.Qty\r\n" & "\t5.UOM\r\n")
(24)Page Life cycle in asp.net
//http://www.codeproject.com/KB/aspnet/lifecycle.aspx
(24a)Preinit
In this Page level event, all controls created during design time are initialized with their default values. For e.g., if you have a TextBox control with Text property = “Hello", it would be set by now. We can create dynamic controls here. This event occurs only for the Page class and UserControls/MasterPages do not have this method to override.
Note that PreInit() is the only event where we can set themes programmatically.
(24b)Oninit
In this event, we can read the controls properties (set at design time). We cannot read control values changed by the user because that changed value will get loaded after LoadPostData() event fires. But we can access control values from the forms POST data as
string selectedValue = Request.Form[controlID].ToString();
Here the runtime de-serializes the view state data from the hidden form element and loads all controls who have view state enabled.
(24c) PreLoad
Use this event if you need to perform processing on your page or control before the Load event.After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
(24d)Page_Load
This is the most popular method and the first one for all beginner developers to put their code. Beginners may also think that this is the first method which fires for a Page class. This can lead to a lot of confusion which makes understanding the Page lifecycle all the more important.
(24e)Control Event Handlers
These are basically event handlers (like Button1_Click()) which are defined for controls in the ASPX markup. Another source of confusion arises when the developer thinks that an event handler like Button_Click() should fire independently (like in windows apps) as soon as he clicks a Button on the web form, forgetting that Page_Load will fire first before any event handlers.
(24f)PreRender
This event is again recursively fired for each child controls in the Page. If we want to make any changes to control values, this is the last event we have to peform the same. PreRender step a good place to make final modifications, such as changing properties of controls or changing Control Tree structure, without having to worry about ASP.NET making changes to objects based off of database calls or viewstate updates. After the PreRender phase those changes to objects are locked in and can no longer be saved to the page viewstate. The PreRender step can be overridden using OnPreRender
(24g)Render
In this method all controls are rendered recursively (i.e. Render method of each control is called). The Render event commences the building of the page by assembling the HTML for output to the browser. During the Render event, the page calls on the objects to render themselves into HTML. The page then collects the HTML for delivery.
(24h)Unload
Here you can have the page and controls perform clean-up operations. This event has no relevance besides clean up operations because the Page has already rendered.