IMportant link of sending sms

May 15, 2013 |

here is some valuable link for sending sms

after following these link i have added sending sms in my project and it is working fine


http://weblogs.asp.net/rajneesh-verma/archive/2011/10/17/sending-sms-through-asp-net-using-sms-sending-api-from-providers.aspx
http://www.rajneeshverma.com/post/2011/10/16/Sending-SMS-through-ASPNET-using-SMS-sending-API-from-providers.aspx
Rajneesh 




Whatever wife lectures the violent baffle. 

first of all i will let you know one thing
you need to buy an api for that or you can take a demo

this code is working fine in my project

  
   2:  
   3: protected void btnSendMessage_Click(object sender, EventArgs e)
   4:     {
   5:         string senderusername = "xxxxx";
   6:         string senderpassword = "xxxx";
   7:         string senderid = "xxx";        
   8:         string sURL;
   9:         StreamReader objReader;
  10:         sURL = "http://thundersms.com/smsapps/pushsms.php?username=" + senderusername + "&password=" + senderpassword + "&sender=" + senderid + "&mobile=91" + txtMobileNumber.Text + "&type=1&message=" + txtMessage.Text;
  11:         WebRequest wrGETURL;
  12:         wrGETURL = WebRequest.Create(sURL);
  13:         try
  14:         {
  15:             Stream objStream;
  16:             objStream = wrGETURL.GetResponse().GetResponseStream();
  17:             objReader = new StreamReader(objStream);
  18:             objReader.Close();
  19:         }
  20:         catch (Exception ex)
  21:         {
  22:             ex.ToString();
  23:         }
  24:     }
  25:  

exception handling

|

try
{
   // Problematic code goes here (i.e. opening a file, connecting to a database).
}
catch
{
   // An error has been detected. You can deal with it here.
}
finally
{
   // Clean up code here, regardless of whether or not there is an error
}
 
 
 
 
for example
 
if (IsPostBack == false)
        {
            try
            {
                SqlConnection con = new SqlConnection(Data.connect);
                SqlDataAdapter da = new SqlDataAdapter("select * from StudI", con);
                SqlCommandBuilder cm = new SqlCommandBuilder(da);
                DataSet ds = new DataSet();
                da.Fill(ds, "Stud_Info");
                if (ds.Tables["Stud_Info"].Rows.Count > 0)
                {
                    GridView1.DataSource = ds.Tables["Stud_Info"];
                    GridView1.DataBind();
                }
            }
            catch(Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert(' " + ex.Message.ToString() + "')</script>");
            }
        } 

How to download data from Grid view to Excel Sheet

April 29, 2013 |

 Charlieform.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Charlieform.aspx.cs" Inherits="Charlieform"
EnableEventValidation="false" %>

<!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>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 1212px;
        }
        .style2
        {
            width: 1019px;
        }
        .style3
        {
            width: 1084px;
        }
        .style5
        {
        }
        .style6
        {
            width: 128px;
            height: 30px;
        }
        .style7
        {
            width: 1084px;
            height: 30px;
        }
        .style8
        {
            height: 30px;
        }
        .style9
        {
            width: 128px;
            height: 33px;
        }
        .style10
        {
            width: 1084px;
            height: 33px;
        }
        .style11
        {
            height: 33px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    <table class="style1">
        <tr>
            <td align="center" class="style5">
                &nbsp;</td>
            <td align="center" colspan="2">
                <asp:Label ID="Label1" runat="server" Text="Student Details"
                    Font-Size="X-Large"></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="center" class="style5" colspan="3">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
               
                    &nbsp;</td>
            <td class="style2" colspan="2">
               
                    <asp:GridView ID="gvdetails" runat="server" AllowPaging="true"
                        AllowSorting="true" AutoGenerateColumns="false" DataSourceID="dsdetails"
                        Height="33px" Width="1046px">
                        <RowStyle BackColor="#EFF3FB" />
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:BoundField DataField="Stud_Name" HeaderText="Name"
                                SortExpression="Stud_Name" />
                            <asp:BoundField DataField="Stud_Year" HeaderText="Year"
                                SortExpression="Stud_Year" />
                            <asp:BoundField DataField="Stud_Address" HeaderText="Address"
                                SortExpression="Stud_Address" />
                            <asp:BoundField DataField="Stud_City" HeaderText="City"
                                SortExpression="Stud_City" />
                            <asp:BoundField DataField="Stud_State" HeaderText="State"
                                SortExpression="Stud_State" />
                            <asp:BoundField DataField="Stud_Country" HeaderText="Country"
                                SortExpression="Stud_Country" />
                            <asp:BoundField DataField="Stud_Email" HeaderText="Email"
                                SortExpression="Stud_Email" />
                            <asp:BoundField DataField="Hostel" HeaderText="Hostel"
                                SortExpression="Hostel" />
                            <asp:BoundField DataField="Stud_Phone" HeaderText="Phone"
                                SortExpression="Stud_Phone" />
                            <asp:BoundField DataField="Entry_Date" HeaderText="Entry Date"
                                SortExpression="Entry_Date" />
                            <asp:BoundField DataField="Exit_Date" HeaderText="Exit Date"
                                SortExpression="Exit_Date" />
                            <asp:BoundField DataField="Stud_Room" HeaderText="Room"
                                SortExpression="Stud_Room" />
                            <asp:BoundField DataField="F_EID" HeaderText="Parents EID"
                                SortExpression="F_EID" />
                                <asp:BoundField DataField="FPH" HeaderText="Parents PH"
                                SortExpression="FPH" />
                        </Columns>
                    </asp:GridView>
                </td>
        </tr>
        <tr>
            <td class="style6">
                </td>
            <td class="style7">
                <asp:SqlDataSource ID="dsdetails" runat="server"
                    ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\data.mdf;Integrated Security=True;User Instance=True"
                    ProviderName="System.Data.SqlClient"
                    SelectCommand="select * from info where Hostel='ct'" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
            <td class="style8">
                </td>
        </tr>
        <tr>
            <td class="style9">
                </td>
            <td class="style10">
                &nbsp;&nbsp;
                <asp:Label ID="Label2" runat="server" Text="DOWNLOAD"
                    Font-Size="X-Large"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:ImageButton ID="btnExcel" runat="server" ImageUrl="~/img/index.jpg"
                    onclick="btnExcel_Click" Height="33px" Width="44px" />
            </td>
            <td class="style11">
                </td>
        </tr>
        <tr>
            <td class="style6">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
                &nbsp;</td>
            <td class="style3">
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Back"
                    Width="151px" />
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
   
</asp:Content>

    </div>
    </form>
</body>
</html>









Charlieform.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Drawing.Imaging;
using System.Design;
using System.Drawing;

public partial class Charlieform : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
    public override void VerifyRenderingInServerForm(Control control)
    {
        /* Verifies that the control is rendered */
    }
  
    protected void btnExcel_Click(object sender, ImageClickEventArgs e)
    {
        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "StudentInfo.xls"));
        Response.ContentType = "application/ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gvdetails.AllowPaging = false;
        gvdetails.DataBind();
        //Change the Header Row back to white color
        gvdetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
        //Applying stlye to gridview header cells
        for (int i = 0; i < gvdetails.HeaderRow.Cells.Count; i++)
        {
            gvdetails.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
        }
        int j = 1;
        //This loop is used to apply stlye to cells based on particular row
        foreach (GridViewRow gvrow in gvdetails.Rows)
        {
            gvrow.BackColor = Color.White;
            if (j <= gvdetails.Rows.Count)
            {
                if (j % 2 != 0)
                {
                    for (int k = 0; k < gvrow.Cells.Count; k++)
                    {
                        gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
                    }
                }
            }
            j++;
        }
        gvdetails.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("charlie.aspx");
    }
    protected void gvdetails_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}