Markup page<asp:FormView ID="DefaultPhoto" runat="server" DataKeyNames="ge_id" DataSourceID="ListPhotosDS"> <EditItemTemplate> <img src="/images/< %# Container.DataItem("photo") %>" class="detailsmallphoto"/> <asp:Label ID="photo_idLabel" runat="server" Text='< %# Eval("photo_id") %>' Visible="false" /> <asp:LinkButton ID="UpdateButton" runat="server" OnClientClick="return confirm('Are you sure you want to remove this photo?');" CommandName="Update" /> </EditItemTemplate> </asp:FormView>
Code behindDirectCast(DefaultPhoto.FindControl("UpdateButton"), LinkButton).Text = "Remove" If Page.isPostBack Then DirectCast(DefaultPhoto.FindControl("UpdateButton"), LinkButton).Text = "Add Photo" End If
Define control properties in code behind located inside gridview or formview
Classic ASP Connection String
Sql connection ************************Dim connStr connStr = "Provider=SQLOLEDB;Data Source=my-sql-server;UID=MyUsernmame; PWD=MyPassword; database=MyDatabase;" Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionTimeOut = 30 objConn.ConnectionString = connStr objConn.Open SET objRS = Server.CreateObject("ADODB.RecordSet") objRS.Open "SELECT * FROM my_table ORDER BY type asc",objConn,1,2 'do some sql work objRS.Close SET objRS = Nothing
Access 2007/2010 connection ************************DIM objConn, objRS, dsn, dbPath dsn = "Driver={Microsoft Access Driver (*.)};Dbq=C:\MyWebsite\databases \MyDatabase2007.accdb;" Set objConn = Server.CreateObject("ADODB.Connection") dbPath = Server.MapPath("MyDatabase2007.accdb") objConn.Open "Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath, "", "" SET objRS = Server.CreateObject("ADODB.RecordSet") objRS.Open "SELECT * FROM my_table ORDER BY id asc",objConn,1,2 'do some sql work objRS.Close SET objRS = Nothing
Access 2003 connection ************************DIM objConn, objRS, dsn, dbPath dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\MyWebsite\databases \MyDatabase2003.mdb;" Set objConn = Server.CreateObject("ADODB.Connection") dbPath = Server.MapPath("MyDatabase.mdb") objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath, "", "" SET objRS = Server.CreateObject("ADODB.RecordSet") objRS.Open "SELECT * FROM my_table ORDER BY id asc",objConn,1,2 'do some sql work objRS.Close SET objRS = Nothing
jQuery Datepicker
To create jQuery Datepicker like this one below do the following:
1. Save the calendar.zip on your computer
2. Unzip the folder and move it to your server
3. Include the js scripts and css style in your page:
– <script src=”/my-website/jcalendar/jquery-1.8.3.js” type=”text/javascript”></script>
– <link href=”/my-website/calendar/jquery-ui.css” rel=”stylesheet” type=”text/css” />
– <script src=”/my-website/calendar/jquery-ui.js” type=”text/javascript”></script>
4. Create textbox (with some html5 validation)
<input type=”text” name=”startDateTbx” id=”datepicker” pattern=”(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d” title=”mm/dd/yyyy” />