Search This Blog

Thursday, April 10, 2014

How to set startup url in asp.net mvc

1.Go to MVC web application property page and set Start Action Specific Page value equal to ControllerName/ActionMethodName ( refer below given screen shot )

Friday, December 20, 2013

What is an action method in MVC

An action method in mvc is a method which can able to redirect user to a view ( an action method can optionally pass model data to a view for rendering views ui filled with model data ).
OR
An action method is a method which is returning ActionResult .

Note: I For testing your knowledge in .net , c , cpp , aptitude , java and arithmetic you can visit the links present http://www.skillgun.com

Important links in skillgun .

arithmetic questions and answers
android interview questions and answers
c interview questions and answers
c++ interview questions and answers
java interview questions and answers
c# interview questions and answers

Tuesday, November 8, 2011

About Global.asax in ASP.NET


  • Global.asax is a file in asp.net
  • Global.asax file contains all the application level methods.like
  •       1.Application_Start 2.Application_End 3.Session_Start 4.Session_End etc..
  • Note: When you compile your code for the first time your ASP.NET runtime creates a class corresponding to Global.asax file with the Class name global_asax. This class inherits from HTTP Application class.
  • You can see the automatically created class in the C:\Documents and Settings\User\My Documents\Visual Studio 2008\WebSites\ApplicationName\global.asax file.

Friday, October 28, 2011

Adding new Nodes to XML File in C#

1.Create a Dummy xml file with the name Patients.xml in your solution explorer.
    Ex:
 <Patients>
  <Patient type="IP">
    <VistorNum>134</VistorNum>
    <FName>Maha</FName>
    <LName>Veer</LName>
    <Age>89</Age>
    <Sex>Male</Sex>
  </Patient>
</Patients>
 
2.Create the UI to accept data from users.(Write the below code in .aspx page)
   VisitorNum:<asp:TextBox ID="tbVstrNum" runat="server" ></asp:TextBox><br />
    FName:<asp:TextBox ID="tbFName" runat="server" ></asp:TextBox><br />
    LName:<asp:TextBox ID="tbLName" runat="server" ></asp:TextBox><br />
    Age:<asp:TextBox ID="tbAge" runat="server" ></asp:TextBox><br />
    Sex:<asp:TextBox ID="tbSex" runat="server" ></asp:TextBox><br />
    <asp:Button ID="btnInsertPat" Text="AddPatient" runat="server" 
            onclick="btnInsertPat_Click" />
3.Write the below code in code behind's button click method.
    protected void btnInsertPat_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("Patients.xml"));
        //Create a New patient node.
        XmlNode nPatient=doc.CreateNode(XmlNodeType.Element,"Patient",null);
        //Create visitornUm,FName,LName,Age,Sex nodes and add 
        //it to Patient Node
        XmlElement eVistNum= doc.CreateElement("VistorNum");
        eVistNum.InnerText = tbVstrNum.Text;
        XmlElement eFName = doc.CreateElement("FName");
        eFName.InnerText = tbFName.Text;
        XmlElement eLName = doc.CreateElement("LName");
        eLName.InnerText = tbLName.Text;
        XmlElement eAge = doc.CreateElement("Age");
        eAge.InnerText = tbAge.Text;
        XmlElement eSex = doc.CreateElement("Sex");
        eSex.InnerText = tbSex.Text;
        nPatient.AppendChild(eVistNum);
        nPatient.AppendChild(eFName);
        nPatient.AppendChild(eLName);
        nPatient.AppendChild(eAge);
        nPatient.AppendChild(eSex);
        //Get the Root Patients Node ref.
        XmlNode root=doc.SelectSingleNode("Patients");
        //Add New patient node to root patient node.
        root.AppendChild(nPatient);
        string sPath = Server.MapPath("Patients.xml");
        doc.Save(sPath);
        //elem.AppendChild(
    }
Sign Up for dot net training course 

Friday, September 9, 2011

Opening My Computer Using ASP.NET

Please use the HTML Input File Control for opening all the available Drives. Just Drag and drop the control
on to the .aspx page and check the result by clicking on the Browse Button.

India's #1 .NET Training

Sunday, August 28, 2011

How to Encrypt Connection String

For security reasons we need to encrypt the connection strings.
Encrypting and decrypting the connection string is very easy. Follow the Below steps to encrypt the Connection strings.
Encrypt Connection Strings:
  • Open visual studio command prompt.
  • type the given command  aspnet_regiis -pef  "connectionStrings"  "YourApplicationFullPath where your web.config file is present"  and then press Enter.


Decrypting Connection String:
  • aspnet_regiis -pdf  "connectionStrings" "YourApplicationFullPath where your web.config file is present"  and then press Enter.


Note : You need to use pef or pdf only if your website is created as a file system. If Your website is created as a IIS website then use pe or pd for encrypting or decrypting.

Thursday, August 18, 2011

is and as operators in C#

is Operator:
  • is operator Checks if an object is compatible with a given type 
  • An is expression evaluates to true if the provided expression is non-null, and the provided object     can  be cast to the provided type without causing  an exception to be thrown.
as Operator:
  • The as operator is used to perform conversions between compatible reference types      
  • The as operator is like a cast operation. However, if the conversion is not possible, as returns null instead of raising an exception
Ex:

public class Exam
{
    public string GetSubjectName()
    {
        return "C#";
    }
}
public class UnitTest
{
    public int GetTestNumber()
    {
        return 1;
    }
}

public partial class CSHARPSAMPLES_Keywords : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Exam e1 = new Exam();
    }
    public void Test(object o)
    {
        if (o is UnitTest)
        {
            UnitTest u = o as UnitTest;
            u.GetTestNumber();
        }
        else if (o is Exam)
        {
            Exam e = o as Exam;
            e.GetSubjectName();
        }
    }
}