在datalist命令上,我编写了这样的代码
protected void DataListShowImgTxt_ItemCommand(object source, DataListCommandEventArgs e)
{
string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
//DataListItem tem = DataListShowImgTxt.Items[e.Item.ItemIndex] as DataListItem;
//TextBox txtcmnet = tem.FindControl("txtcomment") as TextBox;
createDt.commonAll("Select UserName from imagedb where imgid='" + id + "'", "searchimage");
string u_name = createDt.GroupDS.Tables["searchimage"].Rows[0]["UserName"].ToString();
if (e.CommandName == "SaveImage")
{
clickpic =Convert.ToInt32(DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString());
DataListItem teme = DataListShowImgTxt.Items[e.Item.ItemIndex] as DataListItem;
ImageButton imgbtn = teme.FindControl("Image3") as ImageButton;
imglightbox.ImageUrl = imgbtn.ImageUrl;
ScriptManager.RegisterStartupScript(Page, typeof(Page), "ShowValidation", "javascript:ShowImages();", true);
hovercoment(clickpic);
showhoverlikComment(clickpic);
}
if (e.CommandName == "like")
{
////string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
createDt.commonAll("insert into likeimgdb(ImgId,UserName,LikeUser,Status,LikeImgDate) values('" + id + "','" + LoginUser + "','" + u_name + "','Like','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"')", "insertimage");
//LinkButton st = tem.FindControl("LinkButton8") as LinkButton;
if (flag == 0)
{
ShowAllFriendsImage1(LoginUser);
}
else if (flag == 1) {
ShowAllFriendsImage(selectUser);
}
}
我想刷新我的网页只有当命令名是saveimage
时才会刷新我的网页所以请指导我如何刷新它
其实我的设计是这样的
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<% #Eval("Photo")%>' >
<asp:Image ID="Image2" runat="server" ImageUrl='<% #Eval("Photo")%>' Height="60px"
Width="65px" />
</asp:LinkButton>
</td>
<td style="width: 85%">
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="PrfileFName" CssClass="ppppp">
<asp:Label ID="Label1" runat="server" Text='<% #Eval("FullName")%>'></asp:Label>
</asp:LinkButton>
</td>
</tr>
<tr>
<td style="width: 15%">
</td>
<td style="width: 85%">
<asp:LinkButton ID="LinkButton8" runat="server" CommandName="SaveImage" CssClass="ppppp">
save
<asp:ImageButton ID="Image3" runat="server" ImageUrl='<% #Eval("Image")%>' Height="250px"
Width="320px" />
</asp:LinkButton>
</td>
</tr>
<tr>
<td style="width: 15%">
</td>
<td style="width: 85%">
<asp:LinkButton ID="LinkButton9" runat="server" CommandName="like" ToolTip="Like This"
CssClass="qqq">Like</asp:LinkButton> <asp:Label ID="Label5" runat="server"></asp:Label> <asp:LinkButton
ID="LBComnt" runat="server" ToolTip="Leave a Comment" CommandName="Comment" CssClass="qqq">Comment</asp:LinkButton> <asp:Label
ID="Label4" runat="server" Text='<% #Eval("AddDate")%>'></asp:Label>
</td>
</tr>
<%-- comee--%>
<tr>
<td style="width: 15%">
</td>
<td style="width: 85%">
<asp:DataList ID="DataListLikeComnt" runat="server" CssClass="datalistborder" Width="308px">
<ItemTemplate>
<table width="100%">
<tr>
<td style="width: 15%" align="right">
<asp:ImageButton ID="likeimagebutton" runat="server" ImageUrl="~/ProfileImage/like.jpeg"
Width="30%" Height="30%" />
</td>
<td style="width: 85%">
<asp:LinkButton ID="LblLike" runat="server" Text='<% #Eval("CountLike")%>' CssClass="qqq"></asp:LinkButton>
<asp:Label ID="Label6" runat="server" Text="People Likes" CssClass="www"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 15%" align="right">
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/internet_group_chat.png"
Width="30%" Height="30%" />
</td>
<td style="width: 85%">
<asp:LinkButton ID="Lblcoment" runat="server" Text='<% #Eval("CountComment")%>' CssClass="qqq"></asp:LinkButton>
<asp:Label ID="Label7" runat="server" Text="People Comments" CssClass="www"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td style="width: 15%">
</td>
<td style="width: 85%">
<asp:DataList ID="DataListShowComment" runat="server" CssClass="datalistborder" Width="300px">
<ItemTemplate>
<table width="100%" style="background-color: #e9edf1;">
<tr>
<td style="width: 15%">
<asp:LinkButton ID="LinkButton8" runat="server" CssClass="ppppp" CommandName="CommentProfImage">
<asp:Image ID="Image3" runat="server" ImageUrl='<% #Eval("Photo")%>' Height="30px"
Width="30px" />
</asp:LinkButton>
</td>
<td style="width: 85%">
<table width="100%">
<tr>
<td>
<asp:LinkButton ID="LBProfileImage" runat="server" CssClass="ppppp">
<asp:Label ID="Label1" runat="server" CssClass="www" Text='<% #Eval("FullName")%>'></asp:Label>
</asp:LinkButton> <asp:Label ID="Label8" runat="server" CssClass="www" Text='<% #Eval("Comment")%>'></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
我想在commandname = SaveImage上打开图像,并在命令名= like上像counter一样更新 这两个都工作正常,但当我点击它移动到开始页面的位置 我希望它只是更新计数而不是开始
答案 0 :(得分:0)
使用它,
Response.Redirect(Request.RawUrl);
将此代码置于您的状态
if (e.CommandName == "like")
{
////string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
createDt.commonAll("insert into likeimgdb(ImgId,UserName,LikeUser,Status,LikeImgDate) values('" + id + "','" + LoginUser + "','" + u_name + "','Like','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"')", "insertimage");
//LinkButton st = tem.FindControl("LinkButton8") as LinkButton;
if (flag == 0)
{
ShowAllFriendsImage1(LoginUser);
}
else if (flag == 1) {
ShowAllFriendsImage(selectUser);
}
Response.Redirect(Request.RawUrl);
}