Creating custom html controls in mvc

Posted by Unknown 0 comments

                   I have been working with MVC, a lot playing around to make the pages more flexible and easier customization. We have several approaches to create a custom html controls.Here am simply demonstrating how to create a custom label control with HTML Extension.Please check out step by step below

Here i have taken a form with basic simple controls with fist name and last Name
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication1.Views.Home.Index"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns= "http://www.w3.org/1999/xhtml ">
<head id="Head1" runat="server">
     <title>Index</title>
</head>
<body>
      <div>
          <% using (Html.BeginForm())
          { %>

               <label for="firstName">First Name:</label>
               <br />
               <%= Html.TextBox("firstName")%>
               <br /><br />
               <label for="lastName">Last Name:</label>
               <br />

               <%= Html.TextBox("lastName")%>
               <br /><br />
               <input type="submit" value="Register" />    
          <% } %>
     1     </div>
</body>
</html>
I want to change the label in HTML label control, in order to do that we need to create html extension method
using System;
using System.Web.Mvc;

namespace MvcApplication1.Helpers
{
     public static class LabelExtensions
     {
          public static string Label(this HtmlHelper helper, string target, string text)
          {
               return String.Format("<label for='{0}'>{1}</label>", target, text);

          }
     }
}
After creating the build you application successfully, Then you will extension method in Intellisense  of visualstudio

Using the Html.Label() extension method
Then See the code of custom label control

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index3.aspx.cs" Inherits="MvcApplication1.Views.Home.Index3" %>

<%@ Import Namespace="MvcApplication1.Helpers" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
     <title>Index3</title>
</head>
<body>
     <div>

          <% using (Html.BeginForm())
          { %>
               <%= Html.Label("firstName", "First Name:") %>    
               <br />
               <%= Html.TextBox("firstName")%>
               <br /><br />
               <%= Html.Label("lastName", "Last Name:") %>    
               <br />
               <%= Html.TextBox("lastName")%>

               <br /><br />
               <input type="submit" value="Register" />
          <% } %>
     </div>
</body>
</html>
I hope this will help...
Labels:

How to find which process is using which port in windows

Posted by Unknown 0 comments
                                          
How to find which process is using which port in windows

                          Every day we fell in some difficulties and want to know which service is using by which port? Ports are divided into three ranges: The well-known ports (from 0 to 1023), the registered ports (from 1024 to 49151) and Dynamic (Private) ports (from 49152 to 65535). The Internet Assigned Numbers Authority (IANA) is responsible for the global coordination of the port assignment. Here I will show some tools to figure out the problem. Two well-known utility NETSTAT.EXE and TASKLIST.EXE will be used here. 

TASKLIST.EXE is used to know the list of processes with its owing id. When we run >tasklist in command window we see the following output.

Suppose, we want to know which port is used by skype? After running >>tasklist you will see the above output. Here you will see Image Name: Skype.exe with process id or PID: 3224. Now if you want to know which process owes process id or PID 3224? Just run >>tasklist /FI “PID eq 3224”. You will see the following output.



NETSTAT.EXE is used to identify what ports are being used by a particular process. The syntax that we will be using for NETSTAT.EXE is as follows: netstat.exe –a –n –o. Here,
  • -a: listing of all connections and listening ports
  • -n: display address and port numbers in numerical form
  • -o: display the owning PID associated with each connection
Now after running >netstat –a –n –o , you will see the following screen.


If you look at the output, you will see that local address of PID 3224 is 0.0.0.0:55956 which mean process id 3224 used port 55956. You already know that 3224 is the PID of process Skype.exe. So, you came to know that process skype.exe is used port 55956.
Labels:

How to install .net framework 4.5 on iis

Posted by Unknown 0 comments


If you install IIS after installing framework, you have to register framework in IIS. Otherwise you will get following message after hosting asp.net application in IIS. 

ASP.NET 4.5 has not been registered on the Web server. You need to manually configure your Web server for ASP.NET 4.5 in order for your site to run correctly.

You may get error of different version instead of 4.5 according to your configuration. So to register framework in IIS, run the following command in command window.
  • Register framework to IIS without changing existing web applications to use this version of ASP.net
C:\windows\Microsoft.NET\Framework\v4.0.30319->aspnet_regiis –ir
  • Or Installing framework to IIS
C:\windows\Microsoft.NET\Framework\v4.0.30319->aspnet_regiis –i

This installed ASP.NET version v4.0.30319 without updating all script maps. After installing Rational

System Architect XT, the following command was run:
C:\windows\Microsoft.NET\Framework\v4.0.30319->aspnet_regiis -s W3SVC/1/ROOT/SAXT

This installed ASP.NET version v4.0.30319 at the specified application root and its subfolders. All existing script maps in the specified path and below were updated.

For the Rational System Architect XT Web Service add-on product, the Registration tool was run with the following command:
C:\windows\Microsoft.NET\Framework\v4.0.30319->aspnet_regiis -sW3SVC/1/ROOT/SAXTWebService
Labels:
 
test