發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導(dǎo)圖
隨筆
相冊(cè)
原創(chuàng)同步助手
其他工具
圖片轉(zhuǎn)文字
文件清理
AI助手
留言交流
弦斷有誰聽
博客園 首頁(yè) 博問 閃存 新隨筆 聯(lián)系 訂閱 管理 隨筆-3 文章-0 評(píng)論-0
用戶控件開發(fā):
功能: 1、判斷用戶是否自動(dòng)登錄
有了html5,就可以在很多地方用localStorage取代cookies,sessionStorage取代Session 2、實(shí)現(xiàn)視頻搜索 首先為TextBox控件擴(kuò)展一個(gè)AutoCompleteExtender控件,實(shí)現(xiàn)輸入字符,自動(dòng)顯示相關(guān)視頻。 讀者需要了解AutoCompleteExtender控件的使用方法;此實(shí)例后臺(tái)WebService方法如下
數(shù)據(jù)庫(kù)表中有videoTitle字段,通過調(diào)用存儲(chǔ)過程selectVideoTitle create proc [dbo].[selectVideoTitle]@videoTitle nvarchar(20)asselect * from T_videoInfo where videoTitle like '%'+@videoTitle+'%' and aduiting=0 order by clickCount desc 獲得視頻名稱列表,然后傳給strArray; 為TextBox控件添加blur事件,發(fā)生此事件時(shí),會(huì)把TextBox控件的值傳給selectVideoInfo.ashx文件,此文件負(fù)責(zé)返回視頻Id,通過參數(shù)Id傳給videoShow.asox;然后跳轉(zhuǎn)到視頻列表展示頁(yè)面videoShow.aspx
selectVideoInfo如下:
也是通過調(diào)研存儲(chǔ)過程。SqlHelp等一些公共方法在代碼中 3.登錄,注冊(cè)上傳視頻頁(yè)面的打開
當(dāng)希望鏈接被蜘蛛爬到,又不希望通過鏈接形式打開;可以使用return false語句 下面javaScript用來打開注冊(cè)頁(yè)面:
大家可以去查一下window.showModalDialog()和window.open()的區(qū)別等。 代碼
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Configuration;using System.Data;using System.Data.SqlClient;using System.IO;using System.Diagnostics;
namespace 在線視頻.CommonClass{ public class SqlHelp { static string connstr = ConfigurationManager.ConnectionStrings["conVedioStr"].ConnectionString; public static DataTable ExecuteDataTable(string str, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { using (SqlCommand com = conn.CreateCommand()) { com.CommandText = str; com.Parameters.AddRange(parameters); SqlDataAdapter adapter = new SqlDataAdapter(com); DataTable table = new DataTable(); adapter.Fill(table); return table; } } } public static DataTable ExecuteDataTablePro(string procName, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { using (SqlCommand com = conn.CreateCommand()) { com.CommandType = CommandType.StoredProcedure; com.CommandText = procName; com.Parameters.AddRange(parameters); SqlDataAdapter adapter = new SqlDataAdapter(com); DataTable table = new DataTable(); adapter.Fill(table); return table; } } } public static int ExecuteNonQuery(string str, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { conn.Open(); using (SqlCommand com = conn.CreateCommand()) { com.CommandText = str; com.Parameters.AddRange(parameters); return com.ExecuteNonQuery(); } }
} public static int ExecuteNonQueryPro(string procName, params SqlParameter[] parameters) { using (SqlConnection con = new SqlConnection(connstr)) { con.Open(); using(SqlCommand com=con.CreateCommand()) { com.CommandType = CommandType.StoredProcedure; com.CommandText = procName; com.Parameters.AddRange(parameters); return com.ExecuteNonQuery(); } } } public static object ExecuteScalar(string str, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { conn.Open(); using (SqlCommand com = conn.CreateCommand()) { com.CommandText = str; com.Parameters.AddRange(parameters); return com.ExecuteScalar(); }
}
} public static object ExecuteScalarPro(string procName, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { conn.Open(); using (SqlCommand com = conn.CreateCommand()) { com.CommandType = CommandType.StoredProcedure; com.CommandText = procName; com.Parameters.AddRange(parameters); return com.ExecuteScalar(); }
} public static SqlDataReader ExecuteReader(string str, params SqlParameter[] parameters) { using (SqlConnection conn = new SqlConnection(connstr)) { conn.Open(); using (SqlCommand com = conn.CreateCommand()) { com.CommandText = str; com.Connection = conn; com.Parameters.AddRange(parameters); SqlDataReader reader = com.ExecuteReader(); return reader; } }
} public static object FromDbValue(object value) { if (value == DBNull.Value) { return null; } else { return value; } } public static object ToDbValue(object value) { if (value == null) { return DBNull.Value; } else { return value; } } public static string AlertMsg(string msg) { string str = "<script type=\"text/javascript\" >alert('" + msg + "');</script>"; return str; } public static string getUniqueName(string tempPath)//tempPath上傳路徑 { string strPre = tempPath.Substring(0, tempPath.LastIndexOf("."));
string strLast = tempPath.Substring(tempPath.LastIndexOf(".") + 1); int i = 0; while (File.Exists(tempPath)) { tempPath = strPre + "(" + i.ToString() + ")." + strLast; i++; } return tempPath;//返回唯一路徑
} public static void catchImg(string videoFileName, string imgSavePath)//截取圖片 { string fmpeg = @"F:\html\在線視頻\在線視頻\CommonFiles\ffmpeg.exe"; string savePath = imgSavePath; string imgSize = ConfigurationManager.AppSettings["sizeofImg"]; Process pass = new Process(); pass.StartInfo.FileName = fmpeg; pass.StartInfo.Arguments = " -i " + videoFileName + " -y -f image2 -ss 2 -vframes 1 -s " + imgSize + " " + savePath; pass.Start(); }
}}
前臺(tái)代碼:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Header.ascx.cs" Inherits="在線視頻.Header" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<link href="CSS/Header.css" rel="stylesheet" />
<script src="JS/jquery-1.7.1.js"></script>
<script type="text/javascript">
function showDialog(url,width,height) {
var opensettings = "toolbar=no,menubar=no,status=no,scrollbars=no,location=no,resizable=no,center=yes";
//var modalsettings = "center=yes;";
var left, top;
left = (screen.width - width) / 2;
top = (screen.height - height) / 2;
// opensettings = opensettings + ",left=" + left + ",top=" + top+",screenx="+left+",screeny="+top;
var modalsettings = opensettings + ",dialogLeft=" + left + ",dialogTop=" + top;
var d = new Object("dd");
// window.open(url,tarert,opensettings);
window.showModalDialog(url, d, modalsettings);
window.onload = function () {
if (localStorage.userName != null && localStorage.userName != "")
{
document.getElementById("notLogin").style.display ="none";
document.getElementById("spUerName").innerHTML = localStorage.userName;
$(function () {
$("#Header_txtSearch").blur(function () {
$.get("Ajax/selectVideoInfo.ashx", { "videoTitle": $("#Header_txtSearch").val() }, function (data, status) {
if (status == 'success') {
window.location.href = "videoShow.aspx?Id=" + data;
else {
alert("視頻獲取失敗");
});
$("#spUerName").mouseover(function () {
</script>
<div class="divHead">
<div class="divHeader">
<div class="divWeatherInfo" >
<span id="cityName">城市:</span>
<span ><img id="weaPic" src="" alt="無法顯示天氣圖片" /></span>
<span id="temp">溫度:</span>
<span>| 空氣質(zhì)量:</span>
<span id="airQuality"></span>
</div>
<div class="divVideoSearch">
<asp:TextBox ID="txtSearch" runat="server" Height="29px" Width="200px" ></asp:TextBox>
<asp:AutoCompleteExtender ID="txtSearch_AutoCompleteExtender" runat="server" Enabled="True" ServicePath="~/WebService/videoSearch.asmx" TargetControlID="txtSearch" ServiceMethod="GetTextString" MinimumPrefixLength="1" >
</asp:AutoCompleteExtender>
<asp:Button ID="btnSearch" runat="server" Text="搜索" BackColor="#FFECDF" BorderStyle="None" BorderWidth="0px" Font-Bold="True" Font-Italic="False" Font-Size="Large" ForeColor="#FF6E0C" Height="34px" OnClick="btnSearch_Click" Width="70px"/>
<div class="divUserInfo">
<span id="notLogin">
<a href="UserLogin.html" onclick="showDialog('UserLogin.html','200','150');return false;">登錄</a>
<a href="UserRegister.aspx" target="_blank">注冊(cè)</a></span>
<span id="spUerName" ><button id="userCan">退出</button></span>
<a href="videoUpLoad.aspx">上傳</a>
綠色通道: 好文要頂 關(guān)注我 收藏該文與我聯(lián)系
弦斷有誰聽 關(guān)注 - 1 粉絲 - 1
+加關(guān)注
0
(請(qǐng)您對(duì)文章做出評(píng)價(jià))
上一篇:驗(yàn)證碼 下一篇:?jiǎn)挝恢悼丶ǚ?wù)端)開發(fā)(原創(chuàng)由鄭健前輩所寫)
posted @ 2014-02-15 10:21 弦斷有誰聽 閱讀(118) 評(píng)論(0) 編輯 收藏
刷新評(píng)論刷新頁(yè)面返回頂部
注冊(cè)用戶登錄后才能發(fā)表評(píng)論,請(qǐng) 登錄 或 注冊(cè),訪問網(wǎng)站首頁(yè)。 程序員找工作,就在博客園招聘頻道 博客園首頁(yè)博問新聞閃存程序員招聘知識(shí)庫(kù)
最新IT新聞: · 諾基亞 MWC 2014 發(fā)布會(huì)直播預(yù)告,Nokia X 即將揭曉 · 網(wǎng)絡(luò)購(gòu)火車票下月起將驗(yàn)證身份:防止黃牛囤票 · 谷歌智能手表或6月I/O大會(huì)發(fā)布 由LG代工 · Mozilla發(fā)三款Firefox OS新機(jī):最低25美元 · 創(chuàng)業(yè)者自述:選擇正確VC的7個(gè)關(guān)鍵點(diǎn) 更多新聞...
最新知識(shí)庫(kù)文章:
· Node.js 究竟是什么? · Habya'a(臨時(shí)拼湊的組件)與技術(shù)債務(wù) · 關(guān)于在線教育和線下教育的六個(gè)問題 · 別錯(cuò)把需求當(dāng)市場(chǎng) · 瀏覽器中關(guān)于事件的那點(diǎn)事兒
更多知識(shí)庫(kù)文章...
公告
昵稱:弦斷有誰聽園齡:13天粉絲:1關(guān)注:1+加關(guān)注
<
2014年2月
>
日
一
二
三
四
五
六
搜索
常用鏈接 我的隨筆我的評(píng)論我的參與最新評(píng)論我的標(biāo)簽
隨筆檔案2014年2月 (3)
最新評(píng)論
閱讀排行榜
1. 用戶控件開發(fā):(118)2. 驗(yàn)證碼(64)3. 單位值控件(服務(wù)端)開發(fā)(原創(chuàng)由鄭健前輩所寫)(29)
評(píng)論排行榜
1. 驗(yàn)證碼(0)2. 用戶控件開發(fā):(0)3. 單位值控件(服務(wù)端)開發(fā)(原創(chuàng)由鄭健前輩所寫)(0)
推薦排行榜
來自: 昵稱10504424 > 《工作》
0條評(píng)論
發(fā)表
請(qǐng)遵守用戶 評(píng)論公約
Ado.Net連接Mysql數(shù)據(jù)庫(kù)
SqlParameter的作用與用法
二、AddRange方法SqlParameter[] paras = new SqlParameter[] { new SqlParameter(''''''''@name'''''''', ''''...
黑馬程序員
///////////////////簡(jiǎn)化版本,能精確判讀除了傳過來有Sql語句參數(shù),參數(shù)數(shù)組長(zhǎng)度是否為0////////////////長(zhǎng)度可變參數(shù),這樣可以判斷串過來的參數(shù)是否匹配,精確找到自己所對(duì)應(yīng)的方法,完美的結(jié)合了(...
SQLServer 在Visual Studio的2種連接方法
使用 ASP.NET 2.0 ObjectDataSource 控件(整理自msdn)
使用 ASP.NET 2.0 ObjectDataSource 控件(整理自msdn)摘要:ADO.NET 和 SqlDataSource 使得人們可以很容易地訪問 ASP.NET 2.0 中的兩層數(shù)據(jù)。使用 ObjectDataSource 控件編輯數(shù)據(jù)。public void UpdateE...
.net中的4種事務(wù)總結(jié)
淺析Sql Server參數(shù)化查詢
CommandText = "select * from Users where UserName=@UserName"; //傳值 username1,指定參數(shù)長(zhǎng)度為50 //查詢計(jì)劃為(@UserName varchar(50))select * from Users where UserName=@UserName ...
登陸三次錯(cuò)誤提示15分鐘后再試
DateTime lastTime = (DateTime)cmd.SqlDataReader reader = cmd.Show("登陸成功"); //errorTime置0 reader.Close(); cmd.CommandText = "update ...
.net使用中sqlcommand的用法
.net使用中sqlcommand的用法SqlCommand()方法。SqlCommand類的屬性 1.CommandText 獲取或設(shè)置要對(duì)數(shù)據(jù)源執(zhí)行的Transact—SQL語句或存儲(chǔ)過程的名稱。/// </summary> /// <param name="...
微信掃碼,在手機(jī)上查看選中內(nèi)容