Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load ' ' First show a single-argument dialog box with MessageBox.Show. ' MessageBox.Show("Dot Net Perls is awesome.") ' ' Show a two-argument dialog box with this method. ' MessageBox.Show("Dot Net Perls is awesome.", _ "Important Message") ' ' Use a three-argument dialog box with MessageBox.Show. ' ... Also store the result value in a variable slot. ' Dim result1 As DialogResult = MessageBox.Show("Is Dot Net Perls awesome?", _ "Important Question", _ MessageBoxButtons.YesNo) ' ' Use four parameters with the method. ' ... Use the YesNoCancel enumerated constant and the Question icon. ' Dim result2 As DialogResult = MessageBox.Show("Is Dot Net Perls awesome?", _ "Important Query", _ MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Question) ' ' Use five arguments on the method. ' ... This asks a question and you can test the result using the variable. ' Dim result3 As DialogResult = MessageBox.Show("Is Visual Basic awesome?", _ "The Question", _ MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) ' ' Use if-statement with dialog result. ' If result1 = DialogResult.Yes And _ result2 = DialogResult.Yes And _ result3 = DialogResult.No Then MessageBox.Show("You answered yes, yes and no.") ' Another dialog. End If ' ' Use MessageBox.Show overload that has seven arguments. ' MessageBox.Show("Dot Net Perls is the best.", _ "Critical Warning", _ MessageBoxButtons.OKCancel, _ MessageBoxIcon.Warning, _ MessageBoxDefaultButton.Button1, _ MessageBoxOptions.RightAlign, _ True) ' ' Show a dialog box with a single button. ' MessageBox.Show("Dot Net Perls is super.", _ "Important Note", _ MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation, _ MessageBoxDefaultButton.Button1) End Sub End Class
Thursday, June 7, 2012
Message Box In Vb.net
Monday, May 21, 2012
Rounded-Corners for Table
.rounded-corners
{
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
background:#CC0000;
width :40%;
}
OR
write In table Tag
style="border-radius:15px"
Monday, May 14, 2012
upload Image in Gridview vb.net
Import System.IO
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
Dim s As String = FileUpload1.PostedFile.FileName
Dim s1 As String = Path.GetFileName(s)
FileUpload1.PostedFile.SaveAs(Server.MapPath("img/" + s1))
Dim s2 As String = "../img/" + s1
da = New SqlDataAdapter("insert into move(title,director)values('" + TextBox1.Text + "','" + s2 + "')", cn)
ds = New DataSet()
da.Fill(ds)
GridView2.DataSource = ds
GridView2.DataBind()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
Dim s As String = FileUpload1.PostedFile.FileName
Dim s1 As String = Path.GetFileName(s)
FileUpload1.PostedFile.SaveAs(Server.MapPath("img/" + s1))
Dim s2 As String = "../img/" + s1
da = New SqlDataAdapter("insert into move(title,director)values('" + TextBox1.Text + "','" + s2 + "')", cn)
ds = New DataSet()
da.Fill(ds)
GridView2.DataSource = ds
GridView2.DataBind()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Wednesday, May 2, 2012
Textbox with background image using CSS
.searchBox{
background-image
:
url
(
'images/magnifying-glass.gif'
);
background-repeat
:
no-repeat
;
padding-left
:
20px
;
}
Member login |
Tuesday, May 1, 2012
Get Text and Value of Selected Item of ASP.Net RadioButtonList using jQuery
[head>
[script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
[script type="text/javascript">
$("#demo").live("click", function () {
var selectedItem = $("[id*=RadioButtonList1] input:checked");
if (selectedItem.length > 0) {
alert("Selected Value: " + selectedItem.val() + " Selected Text: " + selectedItem.next().html());
} else {
alert("Please select an item.");
}
});
[/script>
[/head>
[body>
[form id="form2" runat="server">
[asp:RadioButtonList ID="RadioButtonList1" runat="server">
[asp:ListItem Text="One" Value="1" />
[asp:ListItem Text="Two" Value="2" />
[asp:ListItem Text="Three" Value="3" />
[/asp:RadioButtonList>
[br />
[input type = "button" id = "Button1" value = "Demo" />
[/form>
[/body>
[/html>
Monday, April 30, 2012
how to make single radio button selection in gridview using javascript
[head id="Head1" runat="server">
[title>Grdview with Arraylist
[style type="text/css">
.Gridview
{
font-family:Verdana;
font-size:10pt;
font-weight:normal;
color:black;
width:300px;
}
[/style>
[script language="javascript" type="text/javascript">
function SelectSingleRadiobutton(rdbtnid) {
var rdBtn = document.getElementById(rdbtnid);
var rdBtnList = document.getElementsByTagName("input");
for (i = 0; i < rdBtnList.length; i++) {
if (rdBtnList[i].type == "radio" && rdBtnList[i].id != rdBtn.id)
{
rdBtnList[i].checked = false;
}
}
}
[/script>
[/head>
[body>
[form id="form1" runat="server">
[div>
[asp:GridView ID="gvdata" runat="server" CssClass="Gridview" AutoGenerateColumns="false" DataKeyNames="UserId" HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White">
[Columns>
[asp:TemplateField>
[ItemTemplate>
[asp:RadioButton id="rdbUser" runat="server" OnClick="javascript:SelectSingleRadiobutton(this.id)" />
[/ItemTemplate>
[/asp:TemplateField>
[asp:BoundField DataField="UserName" HeaderText="Name"/>
[asp:BoundField DataField ="FirstName" HeaderText="FirstName" />
[asp:BoundField DataField="LastName" HeaderText="LastName" />
[asp:BoundField DataField="Location" HeaderText="Location" />
[/Columns>
[/asp:GridView>
[/div>
[/form>
[/body>
[/html>
how to calculate age of person and regular expression for mm/dd/yyyy format using JavaScript
[script type="text/javascript"]
function CalculateAge(birthday)
{
var re=/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$/;
if (birthday.value != '') {
If (re.test(birthday.value)) Then
{
birthdayDate = new Date(birthday.value);
dateNow = new Date();
var years = dateNow.getFullYear() - birthdayDate.getFullYear();
var months=dateNow.getMonth()-birthdayDate.getMonth();
var days=dateNow.getDate()-birthdayDate.getDate();
if (isNaN(years)) {
document.getElementById('lblAge').innerHTML = '';
document.getElementById('lblError').innerHTML = 'Input date is incorrect!';
return false;
}
else {
document.getElementById('lblError').innerHTML = '';
document.getElementById('lblAge').innerHTML = years +' Years ' +months +' months '+days +' days';
}
}
else
{
document.getElementById('lblError').innerHTML = 'Date must be mm/dd/yyyy format';
return false;
}}}
[/script]
[/head>
[body>
[form id="form1" runat="server">
[div>
Date of Birth :
[span style="color: Red">
[asp:Label ID="lblError" runat="server">
[br />
Age : [span id="lblAge">
[/div>
[/form>
[/body>
[/html>
How to disable right click on asp.net web page using JavaScript | Disable mouse right click on webpage
[script language="JavaScript" type="text/javascript"]
//Message to display whenever right click on website
var message = "Sorry, Right Click have been disabled.";
function click(e) {
if (document.all) {
if (event.button == 2 || event.button == 3) {
alert(message);
return false;
}
}
else {
if (e.button == 2 || e.button == 3) {
e.preventDefault();
e.stopPropagation();
alert(message);
return false;
}
}
}
if (document.all) {
document.onmousedown = click;
}
else {
document.onclick = click;
}
[/script]
[/head]
[body]
[form id="form1" runat="server"]
[div]
[/div]
[/form]
[/body]
[/html]
Saturday, April 28, 2012
Watermark Extender
[asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
TargetControlID ="textw" WatermarkText ="Enter Name Please"]
[/asp:TextBoxWatermarkExtender]
[asp:TextBox ID="textw" runat="server"][/asp:TextBox]
Monday, April 23, 2012
Difference between where and having clause
1. The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause.
2. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping.
3. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions.
The HAVING clause allows you to filter the results of aggregate functions,
such as COUNT() or AVG() or SUM(), or MAX() or MIN(), just to name a few.
HAVING provides you a means to filter these results in the same query,
as opposed to saving the results of a WHERE clause SQL statement to a temporary table
and running another query on the temporary table results to extract the same results.
Thursday, March 29, 2012
How can make PDF file in Vb.net
Imports iTextSharp.text
Imports System.IO
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Please Add Above namesapce And Add iTextSharp .dll file in Add Reference,& Edit This Event
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="pdf.aspx.vb" Inherits="pdf" EnableEventValidation="false" %>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=SandeepPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Imports System.IO
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Please Add Above namesapce And Add iTextSharp .dll file in Add Reference,& Edit This Event
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="pdf.aspx.vb" Inherits="pdf" EnableEventValidation="false" %>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=SandeepPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Saturday, March 24, 2012
Delete Data In GridView Vb.net
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
cn = New SqlConnection(" Write Connection String ")
da = New SqlDataAdapter("select * from s_reg", cn)
Dim cmd As SqlCommandBuilder = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds)
ds.Tables(0).Rows(e.RowIndex).Delete()
da.Update(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End Sub
Saturday, March 3, 2012
Create EXE or Setup File in .NET Windows Application
Setup projects allow you to create installers in order to distribute an application. The resulting Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation. When the .msi file is distributed and run on another computer, you can be assured that everything necessary for installation is included; if for any reason the installation fails (for example, the target computer does not have the required operating system version), the installation will be rolled back and the computer returned to its pre-installation state.
The following steps will gives the elegant guidance to create an exe or installer file.




5.You can see the “File System on TargetMachine”under three folders
Application Folder
User’s Desktop
User’s Program Menu

6.Select Application Folder and right click Add>Project Output>select Primary output

7. Select User’s Desktop richt click on the second window>click create new shortcut>select output file from Application folder>change the file name from primary output name to MyEXE

next >>

same procedure follows the user’s program menu also
8.If you want to change the Manufactures name for exe,just right click the project go to properties

change the properties as per you requirement
9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)

EXE or installer will be available on his physical path…

When you want to install the EXE on the client machine,you should be installed .NET Framework on that machine because, Applications and controls written for the .NET Framework v2.0 requires the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs.
1, Go to file menu > click Add > new project >now “Add New Project” dialog will appear.
2.Select the “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project”give name project name in name text box finally click OK.
3.New project appear in solution explorer,for eg., you have give the name “MyEXE” file will be displays with given name.
4.Right click the MyEXE > go View > click “File System”
5.You can see the “File System on TargetMachine”under three folders
Application Folder
User’s Desktop
User’s Program Menu
6.Select Application Folder and right click Add>Project Output>select Primary output
7. Select User’s Desktop richt click on the second window>click create new shortcut>select output file from Application folder>change the file name from primary output name to MyEXE
next >>
same procedure follows the user’s program menu also
8.If you want to change the Manufactures name for exe,just right click the project go to properties
change the properties as per you requirement
9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)
EXE or installer will be available on his physical path…
When you want to install the EXE on the client machine,you should be installed .NET Framework on that machine because, Applications and controls written for the .NET Framework v2.0 requires the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs.
Wednesday, February 29, 2012
GridView vs DataList vs Repeater vs Formview vs DetailsView - which one to choose
Feature | Repeater | DataList | GridView |
Table layout | No | No | Yes |
Flow layout | Yes | Yes | No |
Column layout | No | Yes | No |
Style properties | No | Yes | Yes |
Templates | Yes | Yes | Columns/optional |
Select/ Edit/Delete | No | Yes | Yes |
Sort | No | No | Yes |
Paging | No | No | Yes |
Tuesday, February 28, 2012
What is the difference between a property a method and an event? Give an example of each
1. Text1.color ------ is a property
2. Text1.text ------- is Method
3. button 1. Click -- is an event
What is the difference between a property a method and an event? Give an example of each.
*Property are a type of method that shows state of an Object
like Caption, backcolour etc.
*Methods/Functions are for changing Or doing something on
the Object Like Move,Remove, Add etc.
*Event are Objects which means that something happend for
which the object must respond to. And for this very reason
we write method like
button1_Click( sender Object, event Object)
The event Object(Delegate) is related with the method of
that responder Object(Button)
Monday, February 20, 2012
Fetch the data from Excel File at GridView
1.use this name space:-Imports System.Globalization
2.Add the Excel file in Solution Explorer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillgried()
End Sub
Function fillgrid()
Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Customers1.xlsx") + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'"
Dim query As String = "SELECT * FROM [customers$]"
Dim excelDataSet As DataSet = New DataSet()
excelDataSet.Locale = CultureInfo.InvariantCulture
Dim da As OleDbDataAdapter = New OleDbDataAdapter(query, strConn)
da.Fill(excelDataSet)
GridView1.DataSource = excelDataSet.Tables(0)
GridView1.DataBind()
End Function
2.Add the Excel file in Solution Explorer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillgried()
End Sub
Function fillgrid()
Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Customers1.xlsx") + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'"
Dim query As String = "SELECT * FROM [customers$]"
Dim excelDataSet As DataSet = New DataSet()
excelDataSet.Locale = CultureInfo.InvariantCulture
Dim da As OleDbDataAdapter = New OleDbDataAdapter(query, strConn)
da.Fill(excelDataSet)
GridView1.DataSource = excelDataSet.Tables(0)
GridView1.DataBind()
End Function
Friday, February 17, 2012
Image Gallery using ASP.Net Grid View control
****Start Script*****
[head id="Head1" runat="server"]
[title]GridView Images Example[/title]
[script type="text/javascript"]
function LoadDiv(url) {
var img = new Image();
var bcgDiv = document.getElementById("divBackground");
var imgDiv = document.getElementById("divImage");
var imgFull = document.getElementById("imgFull");
var imgLoader = document.getElementById("imgLoader");
imgLoader.style.display = "block";
img.onload = function () {
imgFull.src = img.src;
imgFull.style.display = "block";
imgLoader.style.display = "none";
};
img.src = url;
var width = document.body.clientWidth;
if (document.body.clientHeight > document.body.scrollHeight) {
bcgDiv.style.height = document.body.clientHeight + "px";
}
else {
bcgDiv.style.height = document.body.scrollHeight + "px";
}
imgDiv.style.left = (width - 650) / 2 + "px";
imgDiv.style.top = "20px";
bcgDiv.style.width = "100%";
bcgDiv.style.display = "block";
imgDiv.style.display = "block";
return false;
}
function HideDiv() {
var bcgDiv = document.getElementById("divBackground");
var imgDiv = document.getElementById("divImage");
var imgFull = document.getElementById("imgFull");
if (bcgDiv != null) {
bcgDiv.style.display = "none";
imgDiv.style.display = "none";
imgFull.style.display = "none";
}
}
[/script]
****End Script***
***Css Start ***
[style type="text/css"]
****End Script***
***Css Start ***
[style type="text/css"]
body
{
margin:0;
padding:0;
height:100%;
overflow-y:auto;
}
.modal
{
display: none;
position: absolute;
top: 0px;
left: 0px;
background-color:black;
z-index:100;
opacity: 0.8;
filter: alpha(opacity=60);
-moz-opacity:0.8;
min-height: 100%;
}
#divImage
{
display: none;
z-index: 1000;
position: fixed;
top: 0;
left: 0;
background-color:White;
height: 550px;
width: 600px;
padding: 3px;
border: solid 1px black;
}
* html #divImage {position:absolute;}
[/style]
***End Css***
***Start Body ***
[body]
[form id="form1" runat="server"]
[div]
[br /]
[asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Font-Names="Arial"]
[Columns]
[asp:TemplateField HeaderText="Preview Image"]
[ItemTemplate]
[asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl='<%# Eval("p_image")%>' Width="50px"
Height="50px" Style="cursor: pointer"
OnClientClick = "return LoadDiv(this.src);"/]
[/ItemTemplate]
[/asp:TemplateField]
[/Columns]
[/asp:GridView]
[/div]
[div id="divBackground" class="modal"]
[/div]
[div id="divImage" class = "info"]
[table style="height: 100%; width: 100%"]
[tr]
[td valign="middle" align="center"]
[img id="imgLoader" alt=""src="images/loader.gif" /]
[img id="imgFull" runat="server" alt="" src=""style="display: none;
height: 500px;width: 590px" /]
[/td]
[/tr]
[tr]
[td align="center" valign="bottom"]
[input id="btnClose" type="button" value="close"onclick="HideDiv()"/]
[/td]
[/tr]
[/table]
[/div]
[/form]
[/body]
[/html]
***End Css***
***Start Body ***
[body]
[form id="form1" runat="server"]
[div]
[br /]
[asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Font-Names="Arial"]
[Columns]
[asp:TemplateField HeaderText="Preview Image"]
[ItemTemplate]
[asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl='<%# Eval("p_image")%>' Width="50px"
Height="50px" Style="cursor: pointer"
OnClientClick = "return LoadDiv(this.src);"/]
[/ItemTemplate]
[/asp:TemplateField]
[/Columns]
[/asp:GridView]
[/div]
[div id="divBackground" class="modal"]
[/div]
[div id="divImage" class = "info"]
[table style="height: 100%; width: 100%"]
[tr]
[td valign="middle" align="center"]
[img id="imgLoader" alt=""src="images/loader.gif" /]
[img id="imgFull" runat="server" alt="" src=""style="display: none;
height: 500px;width: 590px" /]
[/td]
[/tr]
[tr]
[td align="center" valign="bottom"]
[input id="btnClose" type="button" value="close"onclick="HideDiv()"/]
[/td]
[/tr]
[/table]
[/div]
[/form]
[/body]
[/html]
Wednesday, February 15, 2012
Tuesday, February 14, 2012
How do we read data from a XML file and display it in a DataGrid ?
using ReadXML method
DataSet MyDataset= new DataSet ();
MyDataset.ReadXml (Server.MapPath ("sample.xml"));
MyDataGrid.DataSource =MyDataset;
MyDataGrid.DataBind();
DataSet MyDataset= new DataSet ();
MyDataset.ReadXml (Server.MapPath ("sample.xml"));
MyDataGrid.DataSource =MyDataset;
MyDataGrid.DataBind();
Tuesday, February 7, 2012
Select Year by DropDownList
protected void Page_Load(object sender, EventArgs e)
{
if (!(Page.IsPostBack))
{
for (int i = 1980; i < 2020; i++)
DropDownList1.Items.Add(i.ToString());
DropDownList1.Items.Insert(0, "Select Year");
}
}
{
if (!(Page.IsPostBack))
{
for (int i = 1980; i < 2020; i++)
DropDownList1.Items.Add(i.ToString());
DropDownList1.Items.Insert(0, "Select Year");
}
}
Friday, January 20, 2012
update Content of page by admin throw sqldatabase
Admin page...............
Imports System.Data
Imports System.Data.SqlClient
Partial Class admin_Default
Inherits System.Web.UI.Page
Public con As SqlConnection
Public da As SqlDataAdapter
Public ds As DataSet
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con = New SqlConnection("Data Source=OM;Initial Catalog=effort;Integrated Security=True")
da = New SqlDataAdapter("update page set p_title='" + TextBox1.Text + "',p_description='" + TextBox2.Text + "',dec='" + Editor1.Content.ToString + "'", con)
ds = New DataSet
da.Fill(ds)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
client.................................
write namespace....
Function fill() As String
Try
con = New SqlConnection("Data Source=OM;Initial Catalog=effort;Integrated Security=True")
ds = New DataSet
da = New SqlDataAdapter("select * from page", con)
da.Fill(ds)
Label1.Text = ds.Tables(0).Rows(0).Item("dec")
Label2.Text = ds.Tables(0).Rows(1).Item("p_title")
Label3.Text = ds.Tables(0).Rows(2).Item("p_description")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fill()
End Sub
Imports System.Data
Imports System.Data.SqlClient
Partial Class admin_Default
Inherits System.Web.UI.Page
Public con As SqlConnection
Public da As SqlDataAdapter
Public ds As DataSet
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con = New SqlConnection("Data Source=OM;Initial Catalog=effort;Integrated Security=True")
da = New SqlDataAdapter("update page set p_title='" + TextBox1.Text + "',p_description='" + TextBox2.Text + "',dec='" + Editor1.Content.ToString + "'", con)
ds = New DataSet
da.Fill(ds)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
client.................................
write namespace....
Function fill() As String
Try
con = New SqlConnection("Data Source=OM;Initial Catalog=effort;Integrated Security=True")
ds = New DataSet
da = New SqlDataAdapter("select * from page", con)
da.Fill(ds)
Label1.Text = ds.Tables(0).Rows(0).Item("dec")
Label2.Text = ds.Tables(0).Rows(1).Item("p_title")
Label3.Text = ds.Tables(0).Rows(2).Item("p_description")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fill()
End Sub
Friday, January 13, 2012
Update data using Admin Panel
write code at the Admin Page
Add Namespace and add the XML file by Solution Explorer
*********************
Imports System.Xml
Imports System.Web
**********************
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim strxmlpath As String = Server.MapPath("../database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath)
Dim node As XmlNode = doc.DocumentElement.FirstChild
node.InnerText = Editor1.Content.ToString //add the editor on the page
doc.Save(strxmlpath)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Function xmlshwo2()
Try
Dim strxmlpath1 As String = Server.MapPath("../database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath1)
Dim elem As XmlNode = doc.DocumentElement.FirstChild
Editor1.Content = elem.InnerText
doc.Save(strxmlpath1)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
xmlshwo2()
End If
End Sub
write the code on client page
Public Function xmlshow1()
Try
Dim strxmlpath As String = Server.MapPath("~/database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath)
Dim elem As XmlNode = doc.DocumentElement.FirstChild
Label1.Text = elem.InnerText
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
xmlshow1()
End Sub
Add Namespace and add the XML file by Solution Explorer
*********************
Imports System.Xml
Imports System.Web
**********************
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim strxmlpath As String = Server.MapPath("../database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath)
Dim node As XmlNode = doc.DocumentElement.FirstChild
node.InnerText = Editor1.Content.ToString //add the editor on the page
doc.Save(strxmlpath)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Function xmlshwo2()
Try
Dim strxmlpath1 As String = Server.MapPath("../database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath1)
Dim elem As XmlNode = doc.DocumentElement.FirstChild
Editor1.Content = elem.InnerText
doc.Save(strxmlpath1)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
xmlshwo2()
End If
End Sub
write the code on client page
Public Function xmlshow1()
Try
Dim strxmlpath As String = Server.MapPath("~/database/col.xml")
Dim doc As New XmlDocument
doc.Load(strxmlpath)
Dim elem As XmlNode = doc.DocumentElement.FirstChild
Label1.Text = elem.InnerText
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
xmlshow1()
End Sub
Monday, January 9, 2012
Change the background color in same page
***********************
write this code under head> tag
***********************
script type="text/javascript">
function init()
{
document.body.onclick = function()
{
colorChange();
}
function colorChange()
{
var colors = ["red","green","blue","orange","pink"];
var index = Math.floor(Math.random() * 100) % 5;
document.body.style.background = colors[index];
}
}
window.onload = init;
/script>
write this code under head> tag
***********************
script type="text/javascript">
function init()
{
document.body.onclick = function()
{
colorChange();
}
function colorChange()
{
var colors = ["red","green","blue","orange","pink"];
var index = Math.floor(Math.random() * 100) % 5;
document.body.style.background = colors[index];
}
}
window.onload = init;
/script>
Friday, January 6, 2012
Sending Email From Your Gmail Account in C#.net
Use these namespace and add function to your event on which you want to send email.
*****************************************************************
using System.Web
using System.Net
using System.Net.Mail
**********************
public void sendml()
{
try
{
SmtpClient client = new SmtpClient();
MailAddress sendto = new MailAddress("email of other person");
MailAddress from = new MailAddress("youremail");
MailMessage message = new MailMessage(from, sendto);
message.IsBodyHtml = true;
message.Subject = "Test by Sandeep";
string st = "Emp Name:" + TextBox1.Text.ToString() + "
Login Time:" + TextBox2.Text.ToString() + "
Logout Time:" + TextBox3.Text + "
Host Name:" + TextBox4.Text + "
Description:" + TextBox5.Text + "";
message.Body = st;
message.IsBodyHtml = true;
NetworkCredential basicauthantication =new NetworkCredential("emailid@gmail.com", "password");
client.Host = "smtp.gmail.com";
client.UseDefaultCredentials = false;
client.Credentials = basicauthantication;
client.EnableSsl = true;
client.Send(message);
Response.Write("mail has been sent");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
*****************************************************************
using System.Web
using System.Net
using System.Net.Mail
**********************
public void sendml()
{
try
{
SmtpClient client = new SmtpClient();
MailAddress sendto = new MailAddress("email of other person");
MailAddress from = new MailAddress("youremail");
MailMessage message = new MailMessage(from, sendto);
message.IsBodyHtml = true;
message.Subject = "Test by Sandeep";
string st = "Emp Name:" + TextBox1.Text.ToString() + "
Login Time:" + TextBox2.Text.ToString() + "
Logout Time:" + TextBox3.Text + "
Host Name:" + TextBox4.Text + "
Description:" + TextBox5.Text + "";
message.Body = st;
message.IsBodyHtml = true;
NetworkCredential basicauthantication =new NetworkCredential("emailid@gmail.com", "password");
client.Host = "smtp.gmail.com";
client.UseDefaultCredentials = false;
client.Credentials = basicauthantication;
client.EnableSsl = true;
client.Send(message);
Response.Write("mail has been sent");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
Data insert in Gridview
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
public partial class form : System.Web.UI.Page
{
OleDbCommand cmd;
OleDbConnection cn;
OleDbDataAdapter da;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
function();
}
protected void Button2_Click(object sender, EventArgs e)
{
cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Sandeep cmc\\Database21.accdb");
da = new OleDbDataAdapter("insert into userr (name1)values('"+TextBox2.Text+"')", cn);
ds = new DataSet();
da.Fill(ds);
function();
}
public void function()
{
cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Sandeep cmc\\Database21.accdb");
da = new OleDbDataAdapter("select * from userr", cn);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
public partial class form : System.Web.UI.Page
{
OleDbCommand cmd;
OleDbConnection cn;
OleDbDataAdapter da;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
function();
}
protected void Button2_Click(object sender, EventArgs e)
{
cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Sandeep cmc\\Database21.accdb");
da = new OleDbDataAdapter("insert into userr (name1)values('"+TextBox2.Text+"')", cn);
ds = new DataSet();
da.Fill(ds);
function();
}
public void function()
{
cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Sandeep cmc\\Database21.accdb");
da = new OleDbDataAdapter("select * from userr", cn);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
Thursday, January 5, 2012
Show date And Time in many format
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CurrentDate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();
Label3.Text = System.DateTime.Now.ToLongDateString();
Label4.Text = System.DateTime.Now.ToLongTimeString();
Label5.Text = System.DateTime.Now.ToShortDateString();
Label6.Text = System.DateTime.Now.ToShortTimeString();
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CurrentDate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();
Label3.Text = System.DateTime.Now.ToLongDateString();
Label4.Text = System.DateTime.Now.ToLongTimeString();
Label5.Text = System.DateTime.Now.ToShortDateString();
Label6.Text = System.DateTime.Now.ToShortTimeString();
}
}
Subscribe to:
Posts (Atom)