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:

Serialize and Deserialize XML into List<T>

Below are the two methods for serialization and deserialization which take generic list as parameter.

private XDocument Serialize<T>(List<T> paramList)
    {

        var doc = new XDocument();
        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(paramList.GetType());

        System.Xml.XmlWriter writer = doc.CreateWriter();

        serializer.Serialize(writer, paramList);

        writer.Close();   

        return doc;        
    }

private List<T> Deserialize<T>(XDocument doc)
    {
        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List<T>));

        System.Xml.XmlReader reader = doc.CreateReader();

        List<T> result = (List<T>)serializer.Deserialize(reader);
        reader.Close();

        return result;
    }
 So now we can serialize whatever list we want. We don't need to specify the list type every time.
 
// For serialize

List<MyType> list = new List<MyType>();
        list.Add(new MyType());
        list.Add(new MyType() { Name = "Try", Value=123 });
        var xml =   Serialize(list);
        xml.Save(filePath);  // filePath is the location where xml is saved

// For deserialize

var document = new XDocument(XDocument.Load(filePath));
List<MyType> newList = Deserialize<MyType>(document );
Posted by: Mohd Ahmed

Categories: ASP.NET, C#, XML

Tags: