RadioButton validation


Copy the following code and paste in your aspx page and run it….

——————————————————————————————–

<asp:RadioButtonList ID=”RadioButtonList1″ runat=”server” Height=”26px”

RepeatDirection=”Horizontal” style=”font-weight: 700; color: #FF0000″  Width=”91px”> <asp:ListItem>Male</asp:ListItem>

<asp:ListItem>Female</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator11″ runat=”server”

ControlToValidate=”RadioButtonList1″

ErrorMessage=”Select Gender*” Display=”Dynamic”></asp:RequiredFieldValidator>

Html5 controls


Using HTML5 input types in ASP.NET

Introduction

HTML5 introduced several new input types for <INPUT> element. These new input types include number, range, email, url, color, date, datetime and a few more. Though these types are not fully supported by all desktop browsers any ASP.NET developer should know them because newer browser versions will definitely support them. In this Post you will learn the basics of using the new input types.

HTML5 new input types

HTML5 provides the following additional values for the type attribute of <INPUT> tag.

  • Email (email)
  • URL (url)
  • Telephone No. (tel)
  • Number (number)
  • Range (range)
  • Color (color)
  • Date (date)
  • Month (month)
  • Week (week)
  • Time (time)
  • Date Time – UTC (datetime)
  • Date Time – Local (datetime-local)
  • Search (search)

These new input types provide the following three key advantages to web developers:

  • They help you to restrict user entry to a fixed set of values avoiding data entry errors. For example, when you use input type as range the user can only enter or select from a fixed range of values.
  • They allow you to validate user input without using any client side script. For example, when you wish to ensure that email address or URL is in proper format you need not resort to JavaScript to do the job. The input control itself can determine if the entered value is valid or not.
  • Browsers render the <INPUT> tag in a different way depending on the input type. This simplifies data entry for the end user.

It should be noted, however, that not all browsers (desktop versions) support these new input types. Also, there are certain differences (though minor) in the way the input elements are rendered and the way error messages are displayed. For example, consider the following screen shot that shows a same HTML5 page in Chrome 14 and FireFox 7.

In order to see how these new input types work, create a new HTML page and add the following markup to it.

<!DOCTYPE html>

<html lang=”en”>

<head>

<title></title>

</head>

<body>

<form id=”form1″>

 

<p>Email :</p>

<input type=”email” name=”email” />

 

<p>URL :</p>

<input type=”url” name=”url” />

 

<p>Telephone No. :</p>

<input type=”tel” name=”tel” />

 

<p>Number :</p>

<input type=”number” name=”number” min=”1″ max=”10″ step=”2″/>

 

<p>Range :</p>

<input type=”range” name=”range” min=”1″ max=”10″ step=”2″ />

 

<p>Date :</p>

<input type=”date” name=”date” />

 

<p>Month :</p>

<input type=”month” name=”month” />

 

<p>Week :</p>

<input type=”month” name=”week” />

 

<p>UTC Date Time :</p>

<input type=”datetime” name=”utcdatetime” />

 

<p>Local Date Time :</p>

<input type=”datetime-local” name=”localdatetime” />

 

<p>Time :</p>

<input type=”time” name=”time” />

 

<input type=”Submit” value=”Submit” />

</form>

</body>

</html>

 

sending sms using asp.net


download source code

SENDING SMS IN ASP.NET

Introduction:

                In this article we will see how to send sms from our web application using ozeki-Ng-SMS-Getway.

Pre-Requesite:

1)      For sending sms from our asp.net web application we required third party sms-getway which will deliver our messages to user. You can download this Getway from here http://www.ozekisms.com/index.php?owpn=112.

2)      Mobile Phone whith SIM card and Datacable. Which will be used for sending our sms.

Description:

Generally for sending Mail messages from our asp.net application we need the SMTP server which will deliver our mails. Same like this for sending SMS from asp.net  we need SMPP server which will deliver our messages to user. This getway is not a free software it’s paid software but for testing you can get 20 day’s trial edition. From here http://www.ozekisms.com/index.php?owpn=112.

Configuring SMS Getway:

After instalation of oseki-ng we have to configure the setting we need. Follow the follwing step to configure.

1)      Run the ozeki-ng which is runnig on default http://127.0.0.1:9501/

2)      Login with standerd user Admin and 123 pwd.

3)      On left hand side upper corner select the Service provider Connection as shown in digrame.

4)      Select GSM/GPRS modem connection. Before starting this step just connect your Mobile/Modem to system and then click on install. Ozeki-Ng automaticlly search your modem and will install the modem. Now we have done almost sending sms setting for ozeki-ng.

5)      You can add the different user also for that refere this link http://www.ozekisms.com/index.php?owpn=164&info=SQL_sms_example.


Now we are ready to send the sms. We will move to some steps to connect with this ozeki-ng sms getway from our asp.net application.

Using Coading:

1)      Create your asp.net website in C#.

2)      Design the send sms page like bellow.

3)      Write the following code in sentbutton_click event.

 

protected void btnsend_Click(object sender, EventArgs e)

{

try

{

if (txtmono.Text!=String.Empty && txtmsg.Text!=String.Empty)

{

SendMessage();

txtmono.Text = String.Empty;

txtmsg.Text = String.Empty;

lblmsg.Visible = true;

lblmsg.Text = “Message Sented”;

}

else

{

lblmsg.Visible = true;

lblmsg.Text = “Not Sented”;

}

}

catch (Exception)

{

throw;

}

}

private void SendMessage()

{

string _msg = txtmsg.Text;

//we creating the necessary URL string:

string ozSURL = “http://127.0.0.1&#8221;; //where Ozeki NG SMS Gateway is running

string ozSPort = “9501”; //port number where Ozeki NG SMS Gateway is listening

string ozUser = HttpUtility.UrlEncode(“admin”); //username for successful login

string ozPassw = HttpUtility.UrlEncode(“abc123”); //user’s password

string ozMessageType = “SMS:TEXT”; //type of message

string ozRecipients = HttpUtility.UrlEncode(“+91” + txtmono.Text); //who will get the message

string ozMessageData = HttpUtility.UrlEncode(_msg); //body of message

string createdURL = ozSURL + “:” + ozSPort + “/httpapi” +

“?action=sendMessage” +

“&username=” + ozUser +

“&password=” + ozPassw +

“&messageType=” + ozMessageType +

“&recipient=” + ozRecipients +

“&messageData=” + ozMessageData;

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);

//Get response from Ozeki NG SMS Gateway Server and read the answer

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

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

string responseString = respStreamReader.ReadToEnd();

respStreamReader.Close();

myResp.Close();

}

Conclusion:

In this way you can implement the sms sending facility in your asp.net web site. It’s very easy to implement and manage.


scrolling text


if you want to scroll text in your web page

write that text in <Marquee></Marque> tag..

also you can place your images or any data in Marquee tag to scroll..

—————————————————————————–

Example:

<marquee direction=’left’ onMouseOver=’this.stop();’

onMouseOut=’this.start();’ scrollamount=’10’>welcome to ASP.NET Info blog </marquee>

—————————————————————————-

In the above example we can scroll the text in blue color

when we place mousepointer on text it’ll stop scrolling….

and when we remove mouse pointer on text it’ll automatically starts scrolling…

because of onmouseover() and onmouseout() functions…

Select All checkbox in gridview


In .aspx page
<asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”>
<Columns>
<asp:TemplateField>
<HeaderTemplate>SelectAll<br />
<asp:CheckBox ID=”chkSelectAll” runat=”server”
AutoPostBack=”true”
OnCheckedChanged=”chkSelectAll_CheckedChanged” />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID=”chkSelect” runat=”server” />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In .aspx.cs page
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkAll =
(CheckBox)GridView1.HeaderRow.FindControl(“chkSelectAll”);
if (chkAll.Checked == true)
{
foreach (GridViewRow gvRow in GridView1.Rows)
{
CheckBox chkSel = (CheckBox) gvRow.FindControl(“chkSelect”);
chkSel.Checked = true;
}
}
else
{
foreach (GridViewRow gvRow in GridView1.Rows)
{
CheckBox chkSel = (CheckBox)gvRow.FindControl(“chkSelect”);
chkSel.Checked = false;
}
}
}

sending all selected items in gridview to next page


protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(“ImgPath”, typeof(string));
dt.Columns.Add(“Name”, typeof(string));
dt.Columns.Add(“Desc”, typeof(string));
dt.Columns.Add(“Price”, typeof(string));
Session[“datatable”] = null;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[0].FindControl(“chkSelect”);
if (chk != null)
{
if (chk.Checked)
{
try
{
string ImgPath = ((Image)GridView1.Rows[i].Cells[0].FindControl(“image”)).ImageUrl;
string Name = ((Label)GridView1.Rows[i].Cells[0].FindControl(“lblName”)).Text;
string Desc = ((Label)GridView1.Rows[i].Cells[0].FindControl(“lb”)).Text;
string Price = ((Label)GridView1.Rows[i].Cells[0].FindControl(“lblPrice”)).Text;

if (Session[“datatable”] == null)
{
Session.Contents.Clear();
DataRow dr = dt.NewRow();
dr[0] = ImgPath;
dr[1] = Name;
dr[2] = Desc;
dr[3] = Price;
dt.Rows.Add(dr);
Session[“datatable”] = dt;
}
else
{
dt = (DataTable)Session[“datatable”];
DataRow dr = dt.NewRow();
dr[0] = ImgPath;
dr[1] = Name;
dr[2] = Desc;
dr[3] = Price;
dt.Rows.Add(dr);
Session[“datatable”] = dt;
}

}

catch (Exception ex)
{
LblId.Text = ex.Message;

}
}
}

}
Response.Redirect(“~/Home/Receive.aspx”);
}
In Receive Page
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add(“ImgPath”, typeof(string));
dt.Columns.Add(“Name”, typeof(string));
dt.Columns.Add(“Desc”, typeof(string));
dt.Columns.Add(“Price”, typeof(string));
if (Session[“datatable”] != null)
{
dt = (DataTable)Session[“datatable”];
GridView1.DataSource = dt;
GridView1.DataBind();
}
else if (Session[“datatable”] == null)
Label1.Text = “NO Product is Selected…”;

}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}

 
}   

 

Validating Dropdownlist using Javascript


Using Javascript:

<head>

<script type=”text/javascript”>
function Dropdownvalidation(source, args)
{
var DDL2 =

document.getElementById(“<%=DropDownList2.ClientID%>”);
var country =

DDL2.options[DDL2.selectedIndex].value;
if (country == “0”)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
</script>

</head>

<body>

<asp:DropDownList ID=”DropDownList2″ runat=”server” Height=”23px” Width=”131px”>
                    <asp:ListItem Value=”0″>—-Select—-</asp:ListItem>
                    <asp:ListItem Value=”10″>Cash</asp:ListItem>
                    <asp:ListItem Value=”11″>Check</asp:ListItem>
                    <asp:ListItem Value=”12″>Western Union</asp:ListItem>
                    <asp:ListItem Value=”13″>Credit Card</asp:ListItem>
                    <asp:ListItem Value=”14″>PayPal</asp:ListItem>
                    <asp:ListItem Value=”15″>Non-electronic Payment (Money Order)</asp:ListItem>
                </asp:DropDownList>
                <asp:CustomValidator ID=”CustomValidator1″ runat=”server”
                    ClientValidationFunction=”Dropdownvalidation” ControlToValidate=”DropDownList2″
                    ErrorMessage=”Please Select*”></asp:CustomValidator>

</body>