標籤:
---恢複內容開始---
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"/>(有誤 ,用HTML裡的控制項實現)
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();
---恢複內容結束---
標題:
<asp:Label ID="articleTitleLabel" runat="server" />
<a href ="readArticle.aspx?articleTitle=<%#Eval("articleTitle") %>&authorid=<%#Eval ("userID") %>&articleid=<%#Eval ("articleID") %>">
<%#Eval("articleTitle") %>>
</a>
<br />
本文:
<asp:Label ID="articleContentLabel" runat="server" />
<%# Eval("articleContent").ToString().Substring(0,Eval ("articleContent").ToString ().Length >30?30:Eval ("articleContent").ToString ().Length ) %>
</a>
<br />//本文保留前30個字元
.NET