Skip to content

Posts from the ‘Web Development’ Category

26
Oct

How to install and configure Joomla ? Part 2

01

02

03

04

05

06

07

26
Oct

How to install and configure Joomla ? Part 1

Slide1

Slide2

Slide3

Slide4

Slide5

Slide6

Slide7

Slide8

Slide9

Slide10

Slide11

9
Nov

How to code a simple cms with Asp.net and C# Part 1

We are using literal control in asp.net to display html content from database..
He we displaying how to how to display data from database display it into web page.
In the first part we putting separate web forms to display each page.
vs

 

 

 

 

We create a database ,’cms’ and created a table called ‘viewing’ .

db

 

 

 

Each row in table show each pages of our cms.Here showing 5 rows in table.so we have 5 page for this cms.Our pages are ‘Home’,’Products’,’Services’,’About Us’,’Contact Us’.

Sample code for Home Page.Default.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class view : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=Pass123;database=cms");
    SqlCommand cmd = new SqlCommand();
    SqlDataAdapter ada = new SqlDataAdapter();
    DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        cmd.Connection = con;
        dt.Clear();
        cmd.CommandText = "select * from viewing";
        ada.SelectCommand = cmd;
        ada.Fill(dt);

        if (!IsPostBack)
        {

            showpage();

        }

    }

    void showpage()
    {
        Literal1.Text = dt.Rows[0][1].ToString();
        Literal2.Text = dt.Rows[0][2].ToString();
        Literal3.Text = dt.Rows[0][3].ToString();
        Literal4.Text = dt.Rows[0][4].ToString();
        Literal5.Text = dt.Rows[0][5].ToString();
        Literal6.Text = dt.Rows[0][6].ToString();
        Literal7.Text = dt.Rows[0][7].ToString();
        Literal8.Text = dt.Rows[0][8].ToString();
        Literal9.Text = dt.Rows[0][9].ToString();
        Literal10.Text = dt.Rows[0][10].ToString();
        Literal11.Text = dt.Rows[0][11].ToString();
        Literal12.Text = dt.Rows[0][12].ToString();
        Literal13.Text = dt.Rows[0][13].ToString();
    }

}

Sample code for Products Page.Products.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class view : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=Pass123;database=cms");
    SqlCommand cmd = new SqlCommand();
    SqlDataAdapter ada = new SqlDataAdapter();
    DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        cmd.Connection = con;
        dt.Clear();
        cmd.CommandText = "select * from viewing";
        ada.SelectCommand = cmd;
        ada.Fill(dt);

        if (!IsPostBack)
        {

            showpage();

        }

    }

    void showpage()
    {
        Literal1.Text = dt.Rows[1][1].ToString();
        Literal2.Text = dt.Rows[1][2].ToString();
        Literal3.Text = dt.Rows[1][3].ToString();
        Literal4.Text = dt.Rows[1][4].ToString();
        Literal5.Text = dt.Rows[1][5].ToString();
        Literal6.Text = dt.Rows[1][6].ToString();
        Literal7.Text = dt.Rows[1][7].ToString();
        Literal8.Text = dt.Rows[1][8].ToString();
        Literal9.Text = dt.Rows[1][9].ToString();
        Literal10.Text = dt.Rows[1][10].ToString();
        Literal11.Text = dt.Rows[1][11].ToString();
        Literal12.Text = dt.Rows[1][12].ToString();
        Literal13.Text = dt.Rows[1][13].ToString();
    }

}

Download Demo

20
Oct

Sample Code for Send sms via Bulk SMS API Using PHP

Signup from a bulk sms provider.and modify the code according to that http api link.

<?php
$domain     =     "mydomain.co.in";
$uname      =     "myusername";
$pwd          =     "mypassword";
$to             =     "9999000000";//reciever 10 digit number (use
comma (,) for multiple users. eg: 9999999999,8888888888,7777777777)
$sms         =     "test sms";//sms content
$sender     =     "TESTDEMO";// sender id. this may be a number
$route       =     "A";// sending route
$sms = urlencode($sms);
$sender = urlencode($sender);
// set parameters the API for sending sms
$parameters="uname=$uname&pwd=$pwd&senderid=$sender&to=$to&msg=$sms&route=$route";
// call the Api
$fp = fopen("http://$domain/sendsms?$parameters", "r");
$response = stream_get_contents($fp); // get response of API call
echo "Success : ".$response; exit; // if response is a number...........
// this was the message id returned. save it for delivery report..........
// you can use your own logic and functions for
// your requirement...
?>
19
Oct

Version 2 ,Sample Code for Send sms via Bulk SMS API Using C#

Modified version of old post “Sample Code for Send sms via Bulk SMS API Using C#

Signup from a bulk sms provider.and modify the code according to that http api link.

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class Default2 : System.Web.UI.Page
{
   // public string api = "mydomain.co.in/sendsms/myusername/mypassword/SenderID/number(s)/message/route";

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtName.Text = "";
        txtPassword.Text = "";
        txtDomain.Text = "";
        txtSenderId.Text = "";
        txtMobile.Text = "";
        txtMessage.Text = "";
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
          string  mobile = txtMobile.Text;
          string message = txtMessage.Text;
          string username = txtName.Text;
          string password = txtPassword.Text;
          string _sender = txtSenderId.Text;
          string domian = txtDomain.Text;
          string route = txtrout.Text;

          string api = "http://" + domian + "/sendsms/" + username + "/" + password + "/" + _sender + "/" + mobile + "/" + message + "/" + route + "";
          Response.Write(apiFunction(api));
        }
        catch
        {
        }
    }
    protected String apiFunction(string strapi)
    {
        try
        {
            string url = strapi;
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            string getDetails = "Argument=SomeTestArguments";
            ASCIIEncoding sendEncoding = new ASCIIEncoding();
            byte[] byte1 = sendEncoding.GetBytes(getDetails);
            myHttpWebRequest.Method = "POST";
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            myHttpWebRequest.ContentLength = getDetails.Length;
            Stream sendStream = myHttpWebRequest.GetRequestStream();
            sendStream.Write(byte1, 0, byte1.Length);
            sendStream.Close();
            WebResponse myWebResponse = myHttpWebRequest.GetResponse();
            Stream ReceiveStream = myWebResponse.GetResponseStream();
            Encoding readEncoding = System.Text.Encoding.GetEncoding("utf-8");
            StreamReader readStream = new StreamReader(ReceiveStream, readEncoding);
            Char[] read = new Char[256];
            int count = readStream.Read(read, 0, 256);
            String str = "";
            if (count &gt; 0)
            {
                str = new String(read, 0, count);
            }
            readStream.Close();
            myWebResponse.Close();
            return str;// this is the response
        }
        catch (Exception exp)
        {
            string error_msg = exp.Message;
            return "failed";
        }
    }

}

Untitled-1

Demo         Download