Saturday, 9 November 2013

Diff betweeen Jquery and Javascript

Javascript:

JavaScript is a scripting language that was designed for use within a web browser. Typically, JavaScript is used for interface interactions. Slideshows and other interactive components are typically done using JavaScript.


Jquery:

This will work on top of the javascript where it has the script plugins which can use flexible and easy to write functions, event handlers.

Monday, 16 September 2013

get all procedures in SQL server

select * from sysobjects where type ='p' order by crdate desc

                  or

--->>Getting Specified procedure Details

SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
AND name = 'SP_NAME'

Wednesday, 10 July 2013

Getting page name from URL's

         string sourcePath = Request.RawUrl;/*this for mapped URL*/
            string destPath = Request.Url.AbsolutePath;/*this is for URL*/
            System.IO.FileInfo fInfo= new System.IO.FileInfo(sourcePath);
          string pagename=fInfo.Name.ToString();

Monday, 8 July 2013

getting Querystring value from MAPPED URL

-->> pass like{sample.aspx?id=1}    


 if (Request.RawUrl.LastIndexOf("id=") != -1)
            {
                int index = Request.RawUrl.LastIndexOf("id=");
               string  id = Request.RawUrl.Substring(index + 3);
            }

Monday, 24 June 2013

Working With Generics

working with generics

create a class-->>declare the properties/variable-->>with in the class create a Method with inherited one(here it will be inherited from the Interface{Class:Interface})


public class sample:ICreatable
{
  public string ramu {get;set;}

   public void Create(SqlDataReader Reader)
   {
    ramu=Convert.ToString(Reader["DBname"]);
   }
}

/*------this is the list-------*/

List<sample> sampledata = new List<sample>();


public class DAGetList
{
    public static List<T> GetListFromCommand<T>(SqlCommand sqlcmd)
    where T : ICreatable, new()
    {
        List<T> results = new List<T>();
        using (sqlcmd.Connection)
        {
            sqlcmd.Connection.Open();
            SqlDataReader sdr = sqlcmd.ExecuteReader();
            while (sdr.Read())
            {
                T newthing = new T();
                newthing.Create(sdr);
                results.Add(newthing);
            }
        }
        return results;
    }
}

public interface ICreatable
{
    void Create(SqlDataReader reader);
}

Downloading file from Physicalpath in asp.net

string filePath= ConfigurationManager.AppSettings["physicalpath"].ToString() + "Members\\filename";;
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(filePath);
Response.End();

Wednesday, 13 March 2013

Splitting into one string into multiple fields


   string s = 1210-5880;
        string[] s1 = s.Split(new char[] { '-' });
        string f1 = s1[0];
        string f2 = s1[1];

Sunday, 24 February 2013

How to fire onClick event of LinkButton inside gridview in asp.net using c#


.aspx page
 

<asp:gridview ID="GridView1" runat="server" Width="100%" EnableTheming="false" AutoGenerateColumns="false">

<Columns>

<asp:TemplateField HeaderText="Customer ID">

<ItemTemplate>

<asp:LinkButton ID="lnk_CustomerID" Text='<%# Bind("Customer_ID")%>' runat="server" OnClick="lnk_CustomerID_Click"></asp:LinkButton>

</ItemTemplate>


</asp:TemplateField>

<asp:TemplateField HeaderText="Customer Name">

<ItemTemplate>

<asp:Label ID="lbl_CustomerName" Text='<%# Bind("Customer_Name")%>' runat="server"></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Customer Age">

<ItemTemplate>

<asp:Label ID="lbl_CustomerAge" Text='<%# Bind("Customer_Age")%>' runat="server"></asp:Label>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:gridview>


As you can see that I have Link button inside the gridview that in mycase contains the unique values which is Customer ID. Now I want to fire the onclick event of LinkButton to execute some other code, which is to store the Text of LinkButton in a session and then want redirection to the Customer Detail page. Let’s have a look how it can be done.

.cs page

protected void lnk_CustomerID_Click(object sender, EventArgs e)
{
LinkButton link = (LinkButton)sender;
GridViewRow gv = (GridViewRow)(link.Parent.Parent);
LinkButton CustomerID = (LinkButton)gv.FindControl("lnk_CustomerID");
Session["customerid"] = CustomerID.Text;
Response.Redirect("customer_detail.aspx");
}
So this is the way to fire the onclick event of LinkButton inside gridview in asp.net using c#.

Maintaining state for logged Users

  1.    Application.Lock();  
  2.           
  3.         int clickCounter = 0;  
  4.         if(Application["ClickCounter"] !=null)  
  5.         {  
  6.             clickCounter = (int)Application["ClickCounter"];  
  7.         }  
  8.         clickCounter++;  
  9.         Application["ClickCounter"] = clickCounter;  
  10.         Application.UnLock();  
  11.   
  12.         Label1.Text = "Button Clicked: " + clickCounter.ToString() + " times";

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...