Home   Subscribe   Linkedin
  Archive Contact  

How To Send SMS From ASP Page Using C#

For Sending Mail From Asp Page to Any Mobile No :

Preparation :Make an Account On "www.way2sms.com" with valid mobile number.

Step 1: (.aspx page)

First of all setup an aspx page with two TextBoxes And a button

TextBox1=For Mobile No.

TextBox2=For Text .

Button = For Submission .

 

Step 2: (.aspx.cs page)

make a method like  below

public void send(string uid, string password, string message, string no)

                {

                    HttpWebRequest myReq =

                    (HttpWebRequest)WebRequest.Create(“http://ubaid.tk/sms/sms.aspx?uid=” + uid + “&pwd=” + password +

                    “&msg=” + message + “&phone=” + no + “&provider=way2sms”);

                    HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();

                    System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());

                    string responseString = respStreamReader.ReadToEnd();

                    respStreamReader.Close();

                    myResp.Close();

                }

 

Step 3:(OnButtonClick)

Call the method on click of Submit Button -

         

protected void Button1_Click(object sender, EventArgs e)

            {

                   send(“YOURMOBILENO”,”YOURPASSWORD”, TextBox2.Text, TextBox1.Text);

             }

Step 4: 

        Replace YOURMOBILENO with your username on Way2sms And ”YOURPASSWORD” with your way2sms password.

 

Step 5:

       Test The Service By Enter Mobileno in TextBox1 And Message In TextBox2 and click on button .

 

Note:Unable to send Message On DoNotDisturb (DND) Service  Activated Cell Number.

Posted by: Ashwani

Categories: ASP.NET, C#

Tags:

Printing in Silverlight

This is a simple example to print UI Element in Silverlight.Main idea in this approach is to pass the existing gridview itemsSource to another grid which is created at run time.Below is the Code where I have called my Utiltiy Class containing the methods to print .In my case I have used RadGridView

private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
           
            var uf = new Utilities.Print.PrintCustomGrid();
            var grid = uf.CreateGridToPrint(RadGridViewBankBranch);
            if (grid.ItemsSource != null)
                uf.PrintAuditGrid(grid);
            else
            {
                MessageBox.Show("Empty Grid Cannot be Printed");
            }
           
        }

     public  RadGridView CreateGridToPrint(RadGridView uiGrid)
        {
            var gridToPrint = new RadGridView();
            gridToPrint.DataContext = uiGrid.DataContext;
            gridToPrint.ItemsSource = uiGrid.ItemsSource;
            gridToPrint.RowIndicatorVisibility = Visibility.Collapsed;
            gridToPrint.ShowGroupPanel = false;
            gridToPrint.IsFilteringAllowed = false;
            gridToPrint.AutoGenerateColumns = false;
            foreach (GridViewColumn column in       uiGrid.Columns.OfType<GridViewColumn>())
            {
                GridViewColumn newColumn = (GridViewColumn)Activator.CreateInstance(column.GetType());
                //gridToPrint.RowLoaded += GridViewReport_RowLoaded;
                newColumn.CopyPropertiesFrom(column);
                gridToPrint.Columns.Add(newColumn);
            }
            StyleManager.SetTheme(gridToPrint, StyleManager.GetTheme(uiGrid));
            gridToPrint.SortDescriptors.AddRange(uiGrid.SortDescriptors);
            gridToPrint.GroupDescriptors.AddRange(uiGrid.GroupDescriptors);
            gridToPrint.FilterDescriptors.AddRange(uiGrid.FilterDescriptors);
            return gridToPrint;
        }

        public void PrintAuditGrid(UIElement source)
        {
            var doc = new PrintDocument();
            //doc.DocumentName = documentName;

            var offsetY = 0d;
            var totalHeight = 0d;

            var canvas = new Canvas();
            canvas.Children.Add(source);

            doc.PrintPage += (s, e) =>
            {
                e.PageVisual = canvas;

                if (totalHeight == 0)
                {
                    totalHeight = source.DesiredSize.Height;
                }

                Canvas.SetTop(source, -offsetY);

                offsetY += e.PrintableArea.Height;

                e.HasMorePages = offsetY <= totalHeight;
            };
            doc.Print("Paywings" + Guid.NewGuid().ToString().Substring(1, 5));
        }
Posted by: Rishabh Toshniwal

Categories: C#, Silverlight, Telerik

Tags: ,