Literal And Label Control

Difference Between Literal and Label in ASP

The mail difference is the way how the tags are rendered

<asp:Label….Text=”Hello World” ..> ==> <span >Hello World</span>

<asp:Literal…Text=”Hello World” ..> ==> Hello World

The next difference is that the labels can be associated for a certain control in the web forms.
On the other hand literals can be used to add plain English text or Html to the Document.

Hope you got the difference 🙂

 

Asp BeginRequest Event

Use of BeginRequest Event in Asp.Net

It is fired on every Request to the Application .

The order of Execution is as follows

The application events are raised in the following order:
BeginRequest
AuthenticateRequest
PostAuthenticateRequest
AuthorizeRequest
PostAuthorizeRequest
ResolveRequestCache
PostResolveRequestCache
PostMapRequestHandler
AcquireRequestState
PostAcquireRequestState
PreRequestHandlerExecute
The event handler is executed.
PostRequestHandlerExecute
ReleaseRequestState
PostReleaseRequestState
PostUpdateRequestCache
LogRequest.
PostLogRequest
EndRequest

This post Explains on how BeginReest can be used .
A page may be restricted based on some condition as folows.
To do this Implement a class that Inherits the IHttpModule and Implement the Init() and Dispose().
Handle the event BeginRequest As Folows

// In the Init()
context.BeginRequest += new EventHandler(context_BeginRequest);

void context_BeginRequest(object sender, EventArgs e)
{
// Called For every Request to the server
HttpRequest request = ((HttpApplication) sender).Request;
HttpContext context = ((HttpApplication)sender).Context;
string applicationPath = request.Path;

if(applicationPath == “/”)
{
applicationPath = “/Index.aspx”;
}
context.RewritePath(applicationPath);
Debug.WriteLine(“Begin Requst Fired”);

}

Here Whenever “/” is the requests path , the responce is redirected to the “/Index.aspx”.
It can be used for other such scenarios.

Hope It helped you 🙂 .

C# Email Validation

The System.Net.Mail Had the mail address class which can be used to validate Email Ids

public static bool IsValidEmail(string emailaddress)
{
try
{
MailAddress m = new MailAddress(emailaddress);
return true;
}
catch (FormatException)
{
return false;
}
}

The code above can be used to validate Email Ids . If the Email Id is in the wrong format , It throws the Format Exception which in turn can be used as an approach to handle the invalid Email Ids . However The use of regular Expressions is the best approach as It is highly Flexible.

Hope You Liked Reading .Happy Coding 🙂 .

MFplaf.dll Missing Fix

If you have installed the Ultimate N versions of the windows 7 OS you are very likely to get this error and the solution to this is as follows

The error is due to the missing Media Foundation Platform which is a dll that does not come bundled with the Ultimate N versions . N versions of the OS are European versions that does not have the media player and related stuff bundled as a result of the European councils measure to do so .Microsoft has also paid around 50 M Euros as fine for the same says some sources.

So you can download and install these features from the link

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=16546

If you are installing the Microsoft Kinect SDK or the Intel Perceptual SDK you will find this Error .This is just a simple scenario that i have quoted.

Hope you solved your issue and enjoyed reading.

Finding SMTP Server

I wanted to setup an account in my Gmail and I was not sure what my SMTP server on yyy.com was so How to find it out .

Step 1 : Setup the Telnet Client

To do that go to control panel click on programs and then click on add or remove windows features

Make sure the Telnet client is checked 

telnet1

Now Open command prompt and type “ nslookup

Press Enter

Type in the following

set type=mx

which specifies mail server

set timeout=20

Then type in the server you want to ping here i use “gmail.com.”  .Use a “.” at the end.

nslook

 

Here it goes the mail Exchange servers Installed at gmail.com

alt1.gmail-smtp-in.l.google.com

alt2.gmail-smtp-in.l.google.com

alt3.gmail-smtp-in.l.google.com

alt4.gmail-smtp-in.l.google.com

gmail-smtp-in.l.google.com

You can see a value called preference which specifies which server is favourable. Lower the value more favourable it is .

I can use the port 25 and TLS settings on my Gmail to setup a secure Network .

Hope You enjoyed Reading.

Password for a Word Documet

Almost Every one knows we can set passwords for a word document but some of us don’t use it frequently and we might have forgot the feature .This is a post on how to use the the feature in the latest version of Office

Consider I have a file that i have stored all my passwords and I don’t want any one to see the file , This is what I can do

passprotect

passwd1

Click on the File Menu . Click on the Info Tab in the Left .passwd2

You can see a button that says protect document followed by selecting the option Password  . Select the option Encrypt With password.Enter the old and new password.

passwd3

All done when you open the file as you can see below It asks for password simple but Useful.

passwd4

Hope you enjoyed reading.

Android Layout Designing

This Post shows a design idea for designing layouts for Android using Android Studio .

This is a problem most of you may face while designing is when changing from landscape to portrait mode and vv

Here is one Example which was designed in relative layout and when the mode is changed the controls overlap and distorts the UI and when used in a smaller res device no component would show up.

 andlay4 

SOLUTION

1)Use table layouts to design the same .

-Table Layout

     – Table row

           -component (Button)

           -component(Button)

2)use Plain Text instead of Large text or small text components .

3)Use the weight,gravity to arrange the components in the in the table row.

This below given layout is a possible solution to the above said problem . As shown below the layout works well from a 10 inch device to 2.7 inch device and both orientations.

 andr layout 1

and lay 2

This is the used structure for the above shown design.

and lay3

Hope you enjoyed reading.