Wednesday 13 March 2013

some important things or Powerfull point in asp.net


Description:-


                     in this example we explain that there is a many point should covered in this example.there is many sitution at that time the this examle is very useful.

in which Example we can expalin some Powerful or Important point  in Asp.Net

to show example of how to send SMS in asp.net click here Send SMS to user in asp.net

to show example of send Email in asp.net click here send Email with Attechment in asp.net 

to show example of Export Gridview data to PDF in asp.net click here Export gridview data to PDF

How to Create a Alert Box in Aspx.cs  File:-

  Response.Write("<script>alert('the product " +txtcnm.Text + "  is exists in databse plz insert another product name');</script>");
Response.Write("<script>alert('you can insert only  " + dt.Rows[0][0].ToString() + "  record because you are in editin mode');</script>");


How to pass QueryString in Design Time in .Aspx File:-

<ItemTemplate>
               
                  <a href="data.aspx?id=<%# Eval("id")%>" style="text-decoration:none"> <asp:Label ID="Label2" runat="server" Text= '<%# Eval("subject") %>'></asp:Label></a>
            
                </ItemTemplate>
           
How to Find Master Page Control From Content Page:-

 Menu inm = (Menu)this.Master.FindControl("Menu1");

How to add OnmouseOver,onmouseout event at Run Time in Gridview Row:-
protected void  GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                   try
                    {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Binding client side functions to GridView row
                e.Row.Attributes.Add("onmouseover", "mouseIn(this);");
                e.Row.Attributes.Add("onmouseout", "mouseOut(this);");

                }
            }

How to Display Birthady date in date format:-

<asp:TemplateField HeaderText="BirthDate" SortExpression="birthdate">

                    <ItemTemplate>

                        <%# ((DateTime)Eval("birthdate")).ToString("dd/MM/yyyy")%>

                    </ItemTemplate>

                    <EditItemTemplate>

                        <asp:TextBox ID="txtbd" runat="Server" Text='<%# ((DateTime)Eval("birthdate")).ToString("dd/MM/yyyy") %>'></asp:TextBox>
                       
                    </EditItemTemplate>

                </asp:TemplateField>


 IS NOT NULL Example in Query:-

q11 = "SELECT mid FROM oe_exams where  total IS NOT NULL and mid='"+Session["mid"].ToString()+"'";
How to check Date is Same or Not:-
for (int i = 0; i <= 1; i++)
        {
            string s = System.DateTime.Now.ToString("MM/dd/yyyy") + "10:05:05 PM";
            DateTime dt = Convert.ToDateTime(ds.Rows[i][0].ToString());
            string ss = dt.ToString("MM/dd/yyyy") + "10:05:05 PM";
            if (ss.Equals(s))
            {
                if (i == 0)
                    r = "1";
                else
                    r = "2";
            }
           
        }
Example of Switch case in Sql Query:-

 string q = "select r.mid,r.uname,r.photo,o.rankk,CASE WHEN o.total > o.total1 THEN o.total ELSE o.total1 END as pf from Registration24 r INNER JOIN oe_exams o ON r.mid=o.mid order by pf desc";

How to Set Image where image path is get from database query and set at design time:-

<td>
            <%
                Response.Write("<img src='../../Content/"+item.photo+"' alt='ii' width='80' height='80' />");
             %>  </td>


How to Increase Session Timeout in Asp.Net:-


Just open web.config File and paste this below code:



<system.web>
<sessionState timeout="60"></sessionState>
</system.web>

Or

<system.web>
 <sessionState mode="InProc" cookieless="false" timeout="60" />
</system.web>
    Stored Procedure For Connecting two Coloumn and use in where Clause in sqlserver Stored Procedure:


    CREATE PROCEDURE GetContactsByLastName



          @Name nvarchar(MAX)

    AS

    Set @Name = @Name + '%'

    BEGIN

          SET NOCOUNT ON;



          SELECT LastName + ', ' + FirstName as SearchedValue, MiddleName, Suffix, Company, ActiveBit

          From Contacts

          Where (LastName + ', ' + FirstName LIKE @Name)

          Order By LastName + ', ' + FirstName

    END

    GO

     how to get last inserted id in sql server

Insert INTO TABLE_ID (Table_NAME), Values (Table_Products)
DECLARE @ID int;
set @ID = SCOPE_IDENTITY(); 

Insert INTO Table_Products (ID, Product_Name) 
Values (@ID, SomeProduct)

0 comments:

Post a Comment