Site Meter Asp.Net-Csharp,Asp,Ado.Net,Ado,Micosoft,Visualstudio,Visual webgui: November 2009

Thursday, November 26, 2009

Find client and server ip address in asp.net,C#.

Find client and server ip address in asp.net,C#.

To get Server IP Address and Name(ie)where your domain hosted in an server:


1. string strHostName = System.Net.Dns.GetHostName();
2. string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();


To get Client IP address ie system current IP address:

1.Response.Write(Request.ServerVariables["http_user_agent"].ToString());

Your IP address is:
2.Response.Write(Request.ServerVariables["remote_addr"].ToString());

The DNS lookup of the IP address is:
3.Response.Write(Request.ServerVariables["remote_host"].ToString());

The method used to call the page:
4.Response.Write(Request.ServerVariables["request_method"].ToString());

The server's domain name:
5.Response.Write(Request.ServerVariables["server_name"].ToString());

The server's port:
6.Response.Write(Request.ServerVariables["server_port"].ToString());

The server's software:
7.Response.Write(Request.ServerVariables["server_software"].ToString());

Sunday, November 22, 2009

Download application or word or doc or pdf code in asp.net,c#

Download application or word or doc or pdf code in asp.net,c#
if (Page.IsPostBack){

Response.ContentType="application/ms-word";
Response.AddHeader( "content-disposition","attachment; filename=RegistrationFormDownload.pdf");
//Source from server
FileStream sourceFile = new FileStream(@"c:\inetpub\vhosts\www.com\httpdocs\Form.pdf", System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read );
//Source from Local system
FileStream sourceFile = new FileStream(@"system file path", System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read );
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();

Response.BinaryWrite(getContent);
}

Saturday, November 21, 2009

Differences::::Div vs span vs iframe

Differences::::Div vs span vs iframe

Blogger wont allow HTML content you can get full article which is given below from this link.You can download it.. http://www.4shared.com/file/156448190/930b924a/div_vs_frame_vs_span.html


DIV is short for "division" because it divides elements.

span is inline, div a block.span is permitted in a div, but not div in a span.

The main difference is that span element is in-line and usually used for a small chunk of in-line HTML whereas a div (division) element is block-line (which is basically equivalent to having a line-break before and after it) and used to group larger chunks of code.

is a block level element -- it's going to 100% width, and it will line break - and is best used for structure (stands for 'division' -- semantic markup here!)
is inline, it can go next to other elements and is best used for text editing... adding rules to special text in a paragraph, hiding text (like navigation), etc.

Eg;;

The div tag has forced a line break.
The div tag will force a line break.
The div tag has forced a line break.The span tag does not force a line break. There is no line break.


Reference to div tag properties:::: http://www.searchwin.net/spandiv.htm


IFrame and Div are HTML tags. They are only for the layout purposes. Using IFrame, you can view another html file in your main html.
Div is used to display contents in a html page. You can put some text,image, and/or combination to display in a div.

An iframe is like having a hole on your page, and in that hole is another web page. If that page is clicked ONLY that page will refresh so that the rest of the site appears to stay in the same place. It's not valid HTML and is therefore not encouraged because browsers can interpret iframes however they want. An iframe is only a container and the page that goes inside it still needs to be written as usual.

To get small idea to get what is div tag

#framearea {
width: 550px;
height: 150px;
margin-bottom: 10px;
}
.framebody {
overflow: auto;
width: 550px;
height: 150px;
}

...content here...



Using a DIV as variable to write into IFRAME


http://www.devarticles.com/c/a/HTML/The-power-of-DIV-with-IFRAME/

Saturday, November 14, 2009

Installing windows Azure ,

Installing windows Azure SDK7

Prerequist:2
IIS 7.0 has to be configured in Vista.8
ASP.NET Application Development components installed.2

WPIlauncher install(Microsoft Web Platform Installer 2.0 Beta)4

Click on the Web Platform tab and customize the Web Server option with:
ASP.Net, Default Document and CGI (if you want to run fastCGI apps)

Click “Install” when you are ready. You’ll get an opportunity to review your selection,
then the download and install will commence.

Finally, if you are using WCF, you will want to install WCF HTTP Activation. (this is a .Net feature)

On Vista: From the Start menu, choose Settings | Control Panel | Programs | Programs and Features,
Click Turn “windows Features On or Off”, under Microsoft .Net Framework 3.0, select WCF HTTP Activation

On Windows Server 2008 – In Server Manager under Features Summary, choose Add Features – under .Net Framework 3.0 Features, select WCF Activation.

Install the Windows Azure Tools

http://www.microsoft.com/downloads/details.aspx?FamilyID=8d75d4f7-77a4-4adf-bce8-1b10608574bb&displaylang=en

What is Localization,Resource,resx in asp.net,C#.

Please refer the following sites to get idea about What is Localization,Resource,resx in asp.net,C#.


http://www.c-sharpcorner.com/UploadFile/prasham/RESOURCEFILES02132008080733AM/RESOURCEFILES.aspx(About Resource file .resx)

http://www.codeproject.com/KB/aspnet/LocalizationPackage.aspx(about localize)

http://www.west-wind.com/presentations/wwDbResourceProvider/introtolocalization.aspx(Example for localize and resource file)

To retrieve table data using table column in asp.net,C#

SqlDataReader rdr = null;
SqlConnection sqlcon = new SqlConnection("Server=___;Initial Catalog=____;Integrated security=true");
sqlcon.Open();

SqlCommand cmd1 = new SqlCommand("select * from ____;", sqlcon);
rdr = cmd1.ExecuteReader();
while (rdr.Read())
{
string ___ = rdr.GetString(rdr.GetOrdinal("column name"));
string ___ = rdr.GetString(rdr.GetOrdinal("column name"));

}
sqlcon.Close();

Substring in asp.net,c#

To find the last character in a string
string lastCharacter = myString.Substring(myString.Length - 1, 1);
//i.e. the last character is a SubString of myString, one character long, starting one character short of the length of myString

To remove the last two characters of a string
string myNewString = myString.Substring(0, myString.Length - 2);
//i.e. the new string is a SubString 2 characters shorter than myString, starting at the beginning of myString