网页制作的一些有用函数

repeater可以点击内部内容进行跳转并传输值

<ItemTemplate>
<tr>
<td> <a href="readArticle1.aspx(要跳转的地址)?ID=<%#Eval("userID")%>&articleTitle=<%#Eval("articleTitle") %>"><%#Eval("userID")%></td>
<td> <a href="readArticle1.aspx(要跳转的地址)?ID=<%#Eval("userID")%>&articleTitle=<%#Eval("articleTitle") %>"><%#Eval("articleTitle")%></a></td>
</tr>
</ItemTemplate>

 

添加音乐

 <embed src="/佟大为 - 放飞.mp3"(音乐的地址信息)width="1" height="1" type="audio/mpeg" loop="true"(是否循环) autostart="true"(是否自动播放) id="MP3" />

 

页面跳转并传值

if((string)SqlHelper.SqlExecuteScalar("SELECT userID,userPassword FROM users WHERE userID = N‘"+userID.Text +"‘ AND userPassword = ‘"+userPassword.Text +"‘")!=null)
{
string querystr = userID.Text;
Response.Write("<script>alert(‘登录成功‘)</script>");
Response.Redirect("http://localhost:20890/personal.aspx?a=" + querystr + "");
}
else
{
Response.Write("<script>alert(‘登录失败‘)</script>");
}

 

接受传值

userID.Text = Request.QueryString["ID"];
articleTitle.Text = Request.QueryString["articleTitle"];

 

绑定图片(未实现)

<asp:Image ID="Image1" runat="server" Height="212px" Width="179px" src="~\result"/>

 

SqlConnection conn = new SqlConnection(str);
userID.Text = Request.QueryString["a"];
bloglist.DataSource = SqlHelper.SelectDT("Select * From author WHERE userID=N‘" + userID.Text + "‘");
bloglist.DataBind();
conn.Open();
userID.Text = "王恺鹏";
string srcc = "SELECT userPicture FROM users WHERE userID =N‘" + userID.Text + "‘";
SqlCommand cmd = new SqlCommand(srcc, conn);
string result = cmd.ExecuteScalar().ToString();

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。