Thanks for your great support. I am confused whether you have understood my question or not.
My question is ... " EVEN THOUGH I HAVE NOT GIVEN ANY PERMISSION FOR MEMBERS TO EDIT,
YET THEY GET IT, DUE TO BUG"
if they visist the page on my ads, they cannot see the edit function, but if they happen to click the
MyCurrent Ads, they get the list of their posted Ads with The Edit Link, and they can even edit the advt.
How can they edit, when myself as an admin, have disabled all powers to edit.
If they want to post they can post a new advt an cancel the previous one, thats the bes t solution.
My request is how to disable the edit link, inspite not granted any permission.
Hope i have mad e it clear. Pl.provide me a solution oin this base, as my site is live now and i have found this
Bug just yesterday only.
To check it, please visit here. Fill a dummy advt and check it yourself
Thanks
Paggy4u
Paggy4u
Paggy4u
-----------------------------------------
Working with Dynamic Languages
Like Marcgel said you will either do one or the other it sounds like, not both. So if you decide you will allow the user to edit their ad, you can update the ad status to pending again just as if they were entering in a new ad.
Dear Justin,
I have just posted my problem once again for Marcgel. Meantime can you please explain me what exactly the code
provided by Marcgel does. I am unable to understand his solution.
what solution comes out of his code.
(1) Does it bloks Edit Function...?
(2) Does the advt come again as Pending....?
I did not understood, while you said this is a nice slution. Pl. explain me what is the solution that you have understood.
P.S.:- I have just included a VERY GOOD TAB FEATURE in my ContactUs Page. This is a nice feature, where you
would like to save the space and show many things in one page. This TAB is a feature of asp.net 2.0 Have a look there,
It may help many members out here.
Just posted for if anyone would like to implement and have been looking for a solution
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Paggy4u
-----------------------------------------
Working with Dynamic Languages
I included the code for the MyAds page to correct what the intended feature was - which was that if you have editing disabled for ads, then once the ad is created, the user who posted it should see no "edit" functions when selecting any of the options on
the MyAds page. You were correct to point out it was a bug. So yes 1) it stops the "edit" function from showing up, and 2) if an ad is pending approval then once it is approved it moves to the "current ad" list. There is no moving back to a "pending" status.
[This posting is provided "AS IS" with no warranties, and confers no rights.]
First Change, seperating UserInactive Ads and UserPending Ads View.
In the VB code this are already seperated with their respective <asp:View >
so the seperation is not required i think so. Here is the code below for you to check.
<asp:View ID="UserInactiveAdsView" runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="PostAd.aspx?relist={0}"
Text="Relist" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general">
</asp:HyperLinkField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
(2)
<asp:View ID="UserPendingAdsView" runat="server">
<h2 class="section">
My Ads waiting for Activation</h2>
<asp:GridView ID="ActivationAdsGrid" runat="server" DataSourceID="PendingAds" AutoGenerateColumns="False"
BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any pending ads.
</EmptyDataTemplate>
<Columns>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:BoundField HeaderText="Date Added" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general">
</asp:HyperLinkField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
This are both seperated now. Am I right.....?
The changes now in myads.aspx.vb
(1)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
If Not Page.IsPostBack Then ActivationAdsButtonPanel.Visible = settings.AdActivationRequired
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If
End If
End Sub
and second changes in the same page
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView) ' REFER to new view created in markup
Page.SetFocus(ActivationAdsGrid)
End Sub
Sorry... The code does not work.
This does not throw any error, but it still shows the EDIT LINK and EDIT link works
I am raelly stuck here.
Thanks
Paggy4u
Paggy4u
-----------------------------------------
Working with Dynamic Languages
I just checked my code installation and it seems to be working for me. I'm including the complete MyAds.aspx/.vb files to make sure we are using the same code. If this doesn't work then there must be an environment difference?
MyAds.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="MyAds.aspx.vb"
Inherits="MyAds_aspx" Title="My Ads" %>
<%@ Register TagPrefix="uc1" TagName="CategoryDropDown" Src="Controls/CategoryDropDown.ascx" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" Runat="server">
<div id="body">
<div id="search_n_no_browse">
<div id="search">
<fieldset>
<legend>Search</legend>
<asp:TextBox ID="CommonSearchTextBox" Runat="server" CssClass="search_box"
AccessKey="s" />
<uc1:CategoryDropDown ID="CommonCategoryDropDown" Runat="server" SelectOptionVisible="false" />
<asp:Button ID="SearchButton" Runat="server" Text="Search" PostBackUrl="~/Search.aspx" />
<asp:HyperLink ID="AdvancedSearchLink" Runat="server" NavigateUrl="~/AdvancedSearch.aspx">[go to advanced search]</asp:HyperLink>
</fieldset>
</div>
</div>
<div id="content_header">
<a id="content_start"></a>
<h2>
Go to...</h2>
<ul>
<li>
<asp:LinkButton ID="CurrentAdsButton" Runat="server" OnClick="CurrentAdsButton_Click">Current Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="InactiveAdsButton" Runat="server" OnClick="InactiveAdsButton_Click">Inactive Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="SavedAdsButton" Runat="server" OnClick="SavedAdsButton_Click">Saved Bookmarks</asp:LinkButton></li>
<asp:PlaceHolder ID="ActivationAdsButtonPanel" Runat="server"><li>
<asp:LinkButton ID="ActivationAdsButton" Runat="server" OnClick="ActivationAdsButton_Click">Ads waiting for activation</asp:LinkButton></li></asp:PlaceHolder>
<li>
<asp:HyperLink ID="ProfileLink" Runat="server" NavigateUrl="~/MyProfile.aspx">My Profile</asp:HyperLink></li>
</ul>
</div>
<div id="content">
<asp:MultiView ID="MyAdsMultiView" Runat="server" ActiveViewIndex="0">
<asp:View ID="UserAdsView" Runat="server">
<h2 class="section">
My Current Ads</h2>
<asp:GridView ID="CurrentAdsGrid" Runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
OnRowCommand="CurrentAdsGrid_RowCommand" EnableViewState="False" DataKeyNames="Id"
OnRowDataBound="CurrentAdsGrid_RowDataBound" BorderWidth="0" CssClass="item_list"
ShowFooter="True">
<EmptyDataTemplate>
You have no currently active ads.
<asp:HyperLink ID="PostAdLink" Runat="server" NavigateUrl="~/PostAd.aspx">Click here to Post a new Ad.</asp:HyperLink>
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Posted" DataField="DateCreated" SortExpression="DateCreated"
DataFormatString="{0:dd/mm/yy}" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Expires" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:M}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_category" ItemStyle-CssClass="col_category"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
Text="Edit" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:TemplateField HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"><ItemTemplate>
<asp:LinkButton ID="UnlistButton" Runat="server" CommandArgument='<%# Eval("Id") %>'
CommandName="Unlist">Unlist</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserInactiveAdsView" Runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" Runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
Partial Class MyAds_aspx
Inherits System.Web.UI.Page
Protected Sub CurrentAdsGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim adId As Integer = Convert.ToInt32(e.CommandArgument)
AdsDB.ExpireAd(adId, Profile.MemberId)
InactiveAdsGrid.DataBind()
CurrentAdsGrid.DataBind()
End Sub
Protected Sub PendingAds_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Dim inactiveAds As AdsDataComponent.AdsDataTable = CType(e.ReturnValue, AdsDataComponent.AdsDataTable)
If Not (inactiveAds Is Nothing) AndAlso inactiveAds.Rows.Count > 0 Then
ActivationAdsPanel.Visible = True
Else
ActivationAdsPanel.Visible = False
End If
End Sub
Protected Sub CurrentAdsGrid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim UnlistButton As LinkButton = CType(e.Row.FindControl("UnlistButton"), LinkButton)
If Not (UnlistButton Is Nothing) Then '
UnlistButton.Attributes.Add("onclick", "return confirm('Please confirm that you are unlisting this ad. It will no longer appear among the active listings.')")
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings()
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If '
End If
End Sub
Protected Sub CurrentAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserAdsView)
End Sub
Protected Sub InactiveAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserInactiveAdsView)
End Sub
Protected Sub SavedAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(SavedAdsView)
End Sub
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView)
Page.SetFocus(ActivationAdsGrid)
End Sub
End Class
[This posting is provided "AS IS" with no warranties, and confers no rights.]
I just checked my code installation and it seems to be working for me. I'm including the complete MyAds.aspx/.vb files to make sure we are using the same code. If this doesn't work then there must be an environment difference?
MyAds.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="MyAds.aspx.vb"
Inherits="MyAds_aspx" Title="My Ads" %>
<%@ Register TagPrefix="uc1" TagName="CategoryDropDown" Src="Controls/CategoryDropDown.ascx" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" Runat="server">
<div id="body">
<div id="search_n_no_browse">
<div id="search">
<fieldset>
<legend>Search</legend>
<asp:TextBox ID="CommonSearchTextBox" Runat="server" CssClass="search_box"
AccessKey="s" />
<uc1:CategoryDropDown ID="CommonCategoryDropDown" Runat="server" SelectOptionVisible="false" />
<asp:Button ID="SearchButton" Runat="server" Text="Search" PostBackUrl="~/Search.aspx" />
<asp:HyperLink ID="AdvancedSearchLink" Runat="server" NavigateUrl="~/AdvancedSearch.aspx">[go to advanced search]</asp:HyperLink>
</fieldset>
</div>
</div>
<div id="content_header">
<a id="content_start"></a>
<h2>
Go to...</h2>
<ul>
<li>
<asp:LinkButton ID="CurrentAdsButton" Runat="server" OnClick="CurrentAdsButton_Click">Current Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="InactiveAdsButton" Runat="server" OnClick="InactiveAdsButton_Click">Inactive Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="SavedAdsButton" Runat="server" OnClick="SavedAdsButton_Click">Saved Bookmarks</asp:LinkButton></li>
<asp:PlaceHolder ID="ActivationAdsButtonPanel" Runat="server"><li>
<asp:LinkButton ID="ActivationAdsButton" Runat="server" OnClick="ActivationAdsButton_Click">Ads waiting for activation</asp:LinkButton></li></asp:PlaceHolder>
<li>
<asp:HyperLink ID="ProfileLink" Runat="server" NavigateUrl="~/MyProfile.aspx">My Profile</asp:HyperLink></li>
</ul>
</div>
<div id="content">
<asp:MultiView ID="MyAdsMultiView" Runat="server" ActiveViewIndex="0">
<asp:View ID="UserAdsView" Runat="server">
<h2 class="section">
My Current Ads</h2>
<asp:GridView ID="CurrentAdsGrid" Runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
OnRowCommand="CurrentAdsGrid_RowCommand" EnableViewState="False" DataKeyNames="Id"
OnRowDataBound="CurrentAdsGrid_RowDataBound" BorderWidth="0" CssClass="item_list"
ShowFooter="True">
<EmptyDataTemplate>
You have no currently active ads.
<asp:HyperLink ID="PostAdLink" Runat="server" NavigateUrl="~/PostAd.aspx">Click here to Post a new Ad.</asp:HyperLink>
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Posted" DataField="DateCreated" SortExpression="DateCreated"
DataFormatString="{0:dd/mm/yy}" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Expires" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:M}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_category" ItemStyle-CssClass="col_category"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
Text="Edit" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:TemplateField HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"><ItemTemplate>
<asp:LinkButton ID="UnlistButton" Runat="server" CommandArgument='<%# Eval("Id") %>'
CommandName="Unlist">Unlist</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserInactiveAdsView" Runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" Runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
Partial Class MyAds_aspx
Inherits System.Web.UI.Page
Protected Sub CurrentAdsGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim adId As Integer = Convert.ToInt32(e.CommandArgument)
AdsDB.ExpireAd(adId, Profile.MemberId)
InactiveAdsGrid.DataBind()
CurrentAdsGrid.DataBind()
End Sub
Protected Sub PendingAds_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Dim inactiveAds As AdsDataComponent.AdsDataTable = CType(e.ReturnValue, AdsDataComponent.AdsDataTable)
If Not (inactiveAds Is Nothing) AndAlso inactiveAds.Rows.Count > 0 Then
ActivationAdsPanel.Visible = True
Else
ActivationAdsPanel.Visible = False
End If
End Sub
Protected Sub CurrentAdsGrid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim UnlistButton As LinkButton = CType(e.Row.FindControl("UnlistButton"), LinkButton)
If Not (UnlistButton Is Nothing) Then '
UnlistButton.Attributes.Add("onclick", "return confirm('Please confirm that you are unlisting this ad. It will no longer appear among the active listings.')")
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings()
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If '
End If
End Sub
Protected Sub CurrentAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserAdsView)
End Sub
Protected Sub InactiveAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserInactiveAdsView)
End Sub
Protected Sub SavedAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(SavedAdsView)
End Sub
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView)
Page.SetFocus(ActivationAdsGrid)
End Sub
End Class
[This posting is provided "AS IS" with no warranties, and confers no rights.]
Profile is not getting set. MyAds.aspx is pulling the first user's information only. Any additional users will also see the Ads of the first user. I ran some debug code and the MemberId is not getting set for my SelectParameter for any of the objectdatasources
on the MyAds.aspx page.
Is it possible, disallowing the upload mechanism for the photo's at the same time too? The users can not edit now, but they are already able to send "abuse" photo's to their existing ads without Approval of Administrator.
This fix is for the older "beta" version only. For the latest version (the "final" version with a digital signature date of August 2006) the first change you listed has been done already. The second one still needs to be done. In addition, there is a NEW
bug that needs to be fixed. It is NOT in the first version, however somehow it shows up in the newer version. It is a change necessary to allow the Email Notification Link that is sent to the administrator to work correctly.
paggy4u
Contributor
3017 Points
774 Posts
My Question is not understood
Sep 23, 2006 04:01 AM|LINK
Dear Marcgel,
Thanks for your great support. I am confused whether you have understood my question or not.
My question is ... " EVEN THOUGH I HAVE NOT GIVEN ANY PERMISSION FOR MEMBERS TO EDIT,
YET THEY GET IT, DUE TO BUG"
if they visist the page on my ads, they cannot see the edit function, but if they happen to click the
MyCurrent Ads, they get the list of their posted Ads with The Edit Link, and they can even edit the advt.
How can they edit, when myself as an admin, have disabled all powers to edit.
If they want to post they can post a new advt an cancel the previous one, thats the bes t solution.
My request is how to disable the edit link, inspite not granted any permission.
Hope i have mad e it clear. Pl.provide me a solution oin this base, as my site is live now and i have found this
Bug just yesterday only.
To check it, please visit here. Fill a dummy advt and check it yourself
Thanks
Paggy4u
Paggy4u
-----------------------------------------
Working with Dynamic Languages
paggy4u
Contributor
3017 Points
774 Posts
Re: A New Bug Found today.
Sep 23, 2006 04:13 AM|LINK
Paggy:
Like Marcgel said you will either do one or the other it sounds like, not both. So if you decide you will allow the user to edit their ad, you can update the ad status to pending again just as if they were entering in a new ad.
Dear Justin,
I have just posted my problem once again for Marcgel. Meantime can you please explain me what exactly the code
provided by Marcgel does. I am unable to understand his solution.
what solution comes out of his code.
(1) Does it bloks Edit Function...?
(2) Does the advt come again as Pending....?
I did not understood, while you said this is a nice slution. Pl. explain me what is the solution that you have understood.
This is urgent buddy.
Thanks
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
P.S.:- I have just included a VERY GOOD TAB FEATURE in my ContactUs Page. This is a nice feature, where you
would like to save the space and show many things in one page. This TAB is a feature of asp.net 2.0 Have a look there,
It may help many members out here.
Just posted for if anyone would like to implement and have been looking for a solution
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------
Working with Dynamic Languages
marcgel
Member
405 Points
76 Posts
Microsoft
Re: A New Bug Found today.
Sep 23, 2006 05:53 AM|LINK
I included the code for the MyAds page to correct what the intended feature was - which was that if you have editing disabled for ads, then once the ad is created, the user who posted it should see no "edit" functions when selecting any of the options on the MyAds page. You were correct to point out it was a bug. So yes 1) it stops the "edit" function from showing up, and 2) if an ad is pending approval then once it is approved it moves to the "current ad" list. There is no moving back to a "pending" status.
paggy4u
Contributor
3017 Points
774 Posts
The code does not work
Sep 25, 2006 11:15 AM|LINK
Hi Marcgel.
I made the changes as follows
MYADS.ASPX
First Change, seperating UserInactive Ads and UserPending Ads View.
In the VB code this are already seperated with their respective <asp:View >
so the seperation is not required i think so. Here is the code below for you to check.
<asp:View ID="UserInactiveAdsView" runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="PostAd.aspx?relist={0}"
Text="Relist" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general">
</asp:HyperLinkField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
(2)
<asp:View ID="UserPendingAdsView" runat="server">
<h2 class="section">
My Ads waiting for Activation</h2>
<asp:GridView ID="ActivationAdsGrid" runat="server" DataSourceID="PendingAds" AutoGenerateColumns="False"
BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any pending ads.
</EmptyDataTemplate>
<Columns>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:BoundField HeaderText="Date Added" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general">
</asp:HyperLinkField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
This are both seperated now. Am I right.....?
The changes now in myads.aspx.vb
(1)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
' Allow users to upload photos:
ActivationAdsGrid.Columns((ActivationAdsGrid.Columns.Count - 1)).Visible = settings.AllowImageUploads
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 2)).Visible = settings.AllowImageUploads
If Not Page.IsPostBack Then
ActivationAdsButtonPanel.Visible = settings.AdActivationRequired
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If
End If
End Sub
and second changes in the same page
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView)
' REFER to new view created in markup
Page.SetFocus(ActivationAdsGrid)
End Sub
Sorry... The code does not work.
This does not throw any error, but it still shows the EDIT LINK and EDIT link works
I am raelly stuck here.
Thanks
Paggy4u
-----------------------------------------
Working with Dynamic Languages
marcgel
Member
405 Points
76 Posts
Microsoft
Re: The code does not work
Sep 25, 2006 07:09 PM|LINK
I just checked my code installation and it seems to be working for me. I'm including the complete MyAds.aspx/.vb files to make sure we are using the same code. If this doesn't work then there must be an environment difference?
MyAds.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="MyAds.aspx.vb"
Inherits="MyAds_aspx" Title="My Ads" %>
<%@ Register TagPrefix="uc1" TagName="CategoryDropDown" Src="Controls/CategoryDropDown.ascx" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" Runat="server">
<div id="body">
<div id="search_n_no_browse">
<div id="search">
<fieldset>
<legend>Search</legend>
<asp:TextBox ID="CommonSearchTextBox" Runat="server" CssClass="search_box"
AccessKey="s" />
<uc1:CategoryDropDown ID="CommonCategoryDropDown" Runat="server" SelectOptionVisible="false" />
<asp:Button ID="SearchButton" Runat="server" Text="Search" PostBackUrl="~/Search.aspx" />
<asp:HyperLink ID="AdvancedSearchLink" Runat="server" NavigateUrl="~/AdvancedSearch.aspx">[go to advanced search]</asp:HyperLink>
</fieldset>
</div>
</div>
<div id="content_header">
<a id="content_start"></a>
<h2>
Go to...</h2>
<ul>
<li>
<asp:LinkButton ID="CurrentAdsButton" Runat="server" OnClick="CurrentAdsButton_Click">Current Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="InactiveAdsButton" Runat="server" OnClick="InactiveAdsButton_Click">Inactive Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="SavedAdsButton" Runat="server" OnClick="SavedAdsButton_Click">Saved Bookmarks</asp:LinkButton></li>
<asp:PlaceHolder ID="ActivationAdsButtonPanel" Runat="server"><li>
<asp:LinkButton ID="ActivationAdsButton" Runat="server" OnClick="ActivationAdsButton_Click">Ads waiting for activation</asp:LinkButton></li></asp:PlaceHolder>
<li>
<asp:HyperLink ID="ProfileLink" Runat="server" NavigateUrl="~/MyProfile.aspx">My Profile</asp:HyperLink></li>
</ul>
</div>
<div id="content">
<asp:MultiView ID="MyAdsMultiView" Runat="server" ActiveViewIndex="0">
<asp:View ID="UserAdsView" Runat="server">
<h2 class="section">
My Current Ads</h2>
<asp:GridView ID="CurrentAdsGrid" Runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
OnRowCommand="CurrentAdsGrid_RowCommand" EnableViewState="False" DataKeyNames="Id"
OnRowDataBound="CurrentAdsGrid_RowDataBound" BorderWidth="0" CssClass="item_list"
ShowFooter="True">
<EmptyDataTemplate>
You have no currently active ads.
<asp:HyperLink ID="PostAdLink" Runat="server" NavigateUrl="~/PostAd.aspx">Click here to Post a new Ad.</asp:HyperLink>
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Posted" DataField="DateCreated" SortExpression="DateCreated"
DataFormatString="{0:dd/mm/yy}" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Expires" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:M}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_category" ItemStyle-CssClass="col_category"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
Text="Edit" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:TemplateField HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"><ItemTemplate>
<asp:LinkButton ID="UnlistButton" Runat="server" CommandArgument='<%# Eval("Id") %>'
CommandName="Unlist">Unlist</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserInactiveAdsView" Runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" Runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="PostAd.aspx?relist={0}"
Text="Relist" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserPendingAdsView" Runat="server">
<asp:PlaceHolder ID="ActivationAdsPanel" Runat="server"><h2 class="section">
My Ads waiting for Activation</h2>
<asp:GridView ID="ActivationAdsGrid" Runat="server" DataSourceID="PendingAds" AutoGenerateColumns="False"
BorderWidth="0" CssClass="item_list" ShowFooter="True">
<Columns>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:BoundField HeaderText="Date Added" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:PlaceHolder>
</asp:View>
<asp:View ID="SavedAdsView" Runat="server">
<h2 class="section">
My Bookmarks</h2>
<asp:GridView ID="SavedAdsGrid" Runat="server" AutoGenerateColumns="False" DataSourceID="SavedAds"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any saved bookmarks.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/PhotoDisplay.ashx?photoid={0}&size=small"
DataImageUrlField="PreviewImageId" SortExpression="PreviewImageId" HeaderStyle-CssClass="col_photo"
ItemStyle-CssClass="col_photo" AlternateText="Photo representing ad."></asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Date Saved" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns><RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView></asp:View></asp:MultiView>
</div>
</div>
<asp:ObjectDataSource ID="InactiveAds" Runat="server" SelectMethod="GetInactiveAds"
TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB" OldValuesParameterFormatString="{0}"
DeleteMethod="RemoveFromUserList">
<DeleteParameters>
<asp:Parameter Type="Int32" Name="id"></asp:Parameter>
</DeleteParameters>
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="CurrentAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetActiveAds">
<SelectParameters>
<asp:ProfileParameter Name="memberId" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="PendingAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetPendingAds" OnSelected="PendingAds_Selected">
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="SavedAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetSavedAds" DeleteMethod="RemoveSavedAd" OldValuesParameterFormatString="{0}">
<DeleteParameters>
<asp:Parameter Type="Int32" Name="id"></asp:Parameter>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</DeleteParameters>
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource></asp:Content>
MyAds.aspx.vb
Imports System
Imports System.Web.UI.WebControls
Imports AspNet.StarterKits.Classifieds.BusinessLogicLayer
Partial Class MyAds_aspx
Inherits System.Web.UI.Page
Protected Sub CurrentAdsGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim adId As Integer = Convert.ToInt32(e.CommandArgument)
AdsDB.ExpireAd(adId, Profile.MemberId)
InactiveAdsGrid.DataBind()
CurrentAdsGrid.DataBind()
End Sub
Protected Sub PendingAds_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Dim inactiveAds As AdsDataComponent.AdsDataTable = CType(e.ReturnValue, AdsDataComponent.AdsDataTable)
If Not (inactiveAds Is Nothing) AndAlso inactiveAds.Rows.Count > 0 Then
ActivationAdsPanel.Visible = True
Else
ActivationAdsPanel.Visible = False
End If
End Sub
Protected Sub CurrentAdsGrid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim UnlistButton As LinkButton = CType(e.Row.FindControl("UnlistButton"), LinkButton)
If Not (UnlistButton Is Nothing) Then '
UnlistButton.Attributes.Add("onclick", "return confirm('Please confirm that you are unlisting this ad. It will no longer appear among the active listings.')")
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings()
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
' Allow users to upload photos:
ActivationAdsGrid.Columns((ActivationAdsGrid.Columns.Count - 1)).Visible = settings.AllowImageUploads
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 2)).Visible = settings.AllowImageUploads
If Not Page.IsPostBack Then
ActivationAdsButtonPanel.Visible = settings.AdActivationRequired
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If '
End If
End Sub
Protected Sub CurrentAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserAdsView)
End Sub
Protected Sub InactiveAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserInactiveAdsView)
End Sub
Protected Sub SavedAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(SavedAdsView)
End Sub
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView)
Page.SetFocus(ActivationAdsGrid)
End Sub
End Class
marcgel
Member
405 Points
76 Posts
Microsoft
Re: The code does not work
Sep 25, 2006 07:09 PM|LINK
I just checked my code installation and it seems to be working for me. I'm including the complete MyAds.aspx/.vb files to make sure we are using the same code. If this doesn't work then there must be an environment difference?
MyAds.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="MyAds.aspx.vb"
Inherits="MyAds_aspx" Title="My Ads" %>
<%@ Register TagPrefix="uc1" TagName="CategoryDropDown" Src="Controls/CategoryDropDown.ascx" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="Main" Runat="server">
<div id="body">
<div id="search_n_no_browse">
<div id="search">
<fieldset>
<legend>Search</legend>
<asp:TextBox ID="CommonSearchTextBox" Runat="server" CssClass="search_box"
AccessKey="s" />
<uc1:CategoryDropDown ID="CommonCategoryDropDown" Runat="server" SelectOptionVisible="false" />
<asp:Button ID="SearchButton" Runat="server" Text="Search" PostBackUrl="~/Search.aspx" />
<asp:HyperLink ID="AdvancedSearchLink" Runat="server" NavigateUrl="~/AdvancedSearch.aspx">[go to advanced search]</asp:HyperLink>
</fieldset>
</div>
</div>
<div id="content_header">
<a id="content_start"></a>
<h2>
Go to...</h2>
<ul>
<li>
<asp:LinkButton ID="CurrentAdsButton" Runat="server" OnClick="CurrentAdsButton_Click">Current Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="InactiveAdsButton" Runat="server" OnClick="InactiveAdsButton_Click">Inactive Ads</asp:LinkButton></li><li>
<asp:LinkButton ID="SavedAdsButton" Runat="server" OnClick="SavedAdsButton_Click">Saved Bookmarks</asp:LinkButton></li>
<asp:PlaceHolder ID="ActivationAdsButtonPanel" Runat="server"><li>
<asp:LinkButton ID="ActivationAdsButton" Runat="server" OnClick="ActivationAdsButton_Click">Ads waiting for activation</asp:LinkButton></li></asp:PlaceHolder>
<li>
<asp:HyperLink ID="ProfileLink" Runat="server" NavigateUrl="~/MyProfile.aspx">My Profile</asp:HyperLink></li>
</ul>
</div>
<div id="content">
<asp:MultiView ID="MyAdsMultiView" Runat="server" ActiveViewIndex="0">
<asp:View ID="UserAdsView" Runat="server">
<h2 class="section">
My Current Ads</h2>
<asp:GridView ID="CurrentAdsGrid" Runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
OnRowCommand="CurrentAdsGrid_RowCommand" EnableViewState="False" DataKeyNames="Id"
OnRowDataBound="CurrentAdsGrid_RowDataBound" BorderWidth="0" CssClass="item_list"
ShowFooter="True">
<EmptyDataTemplate>
You have no currently active ads.
<asp:HyperLink ID="PostAdLink" Runat="server" NavigateUrl="~/PostAd.aspx">Click here to Post a new Ad.</asp:HyperLink>
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Posted" DataField="DateCreated" SortExpression="DateCreated"
DataFormatString="{0:dd/mm/yy}" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Expires" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:M}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_category" ItemStyle-CssClass="col_category"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
Text="Edit" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:TemplateField HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"><ItemTemplate>
<asp:LinkButton ID="UnlistButton" Runat="server" CommandArgument='<%# Eval("Id") %>'
CommandName="Unlist">Unlist</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserInactiveAdsView" Runat="server">
<h2 class="section">
My Inactive Ads</h2>
<asp:GridView ID="InactiveAdsGrid" Runat="server" DataSourceID="InactiveAds" AutoGenerateColumns="False"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any inactive ads.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/Images/preview-photo.gif" DataImageUrlField="PreviewImageId"
SortExpression="PreviewImageId" ItemStyle-CssClass="col_photo_nopreview" HeaderStyle-CssClass="col_photo_nopreview"
AlternateText="Icon indicating that there are photos for this ad.">
</asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Expired on" DataField="ExpirationDate" SortExpression="ExpirationDate"
NullDisplayText="N/A" DataFormatString="{0:d}" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Views" DataField="NumViews" SortExpression="NumViews"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="# Resp." DataField="NumResponses" SortExpression="NumResponses"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="PostAd.aspx?relist={0}"
Text="Relist" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:View>
<asp:View ID="UserPendingAdsView" Runat="server">
<asp:PlaceHolder ID="ActivationAdsPanel" Runat="server"><h2 class="section">
My Ads waiting for Activation</h2>
<asp:GridView ID="ActivationAdsGrid" Runat="server" DataSourceID="PendingAds" AutoGenerateColumns="False"
BorderWidth="0" CssClass="item_list" ShowFooter="True">
<Columns>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:HyperLinkField>
<asp:BoundField HeaderText="Date Added" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ManagePhotos.aspx?id={0}"
Text="Photos" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:HyperLinkField>
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
</asp:PlaceHolder>
</asp:View>
<asp:View ID="SavedAdsView" Runat="server">
<h2 class="section">
My Bookmarks</h2>
<asp:GridView ID="SavedAdsGrid" Runat="server" AutoGenerateColumns="False" DataSourceID="SavedAds"
DataKeyNames="Id" BorderWidth="0" CssClass="item_list" ShowFooter="True">
<EmptyDataTemplate>
You do not have any saved bookmarks.
</EmptyDataTemplate>
<Columns>
<asp:ImageField DataImageUrlFormatString="~/PhotoDisplay.ashx?photoid={0}&size=small"
DataImageUrlField="PreviewImageId" SortExpression="PreviewImageId" HeaderStyle-CssClass="col_photo"
ItemStyle-CssClass="col_photo" AlternateText="Photo representing ad."></asp:ImageField>
<asp:HyperLinkField HeaderText="Title" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowAd.aspx?id={0}"
DataTextField="Title" AccessibleHeaderText="Title" HeaderStyle-CssClass="col_title"
ItemStyle-CssClass="col_title"></asp:HyperLinkField>
<asp:BoundField HeaderText="Category" DataField="CategoryName" SortExpression="CategoryName"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:BoundField HeaderText="Date Saved" DataField="DateCreated" SortExpression="DateAdded"
HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general"></asp:BoundField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Remove" HeaderStyle-CssClass="col_general"
ItemStyle-CssClass="col_general"></asp:CommandField>
</Columns><RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView></asp:View></asp:MultiView>
</div>
</div>
<asp:ObjectDataSource ID="InactiveAds" Runat="server" SelectMethod="GetInactiveAds"
TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB" OldValuesParameterFormatString="{0}"
DeleteMethod="RemoveFromUserList">
<DeleteParameters>
<asp:Parameter Type="Int32" Name="id"></asp:Parameter>
</DeleteParameters>
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="CurrentAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetActiveAds">
<SelectParameters>
<asp:ProfileParameter Name="memberId" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="PendingAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetPendingAds" OnSelected="PendingAds_Selected">
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="SavedAds" Runat="server" TypeName="AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB"
SelectMethod="GetSavedAds" DeleteMethod="RemoveSavedAd" OldValuesParameterFormatString="{0}">
<DeleteParameters>
<asp:Parameter Type="Int32" Name="id"></asp:Parameter>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</DeleteParameters>
<SelectParameters>
<asp:ProfileParameter Name="memberId" DefaultValue="0" Type="Int32" PropertyName="MemberId"></asp:ProfileParameter>
</SelectParameters>
</asp:ObjectDataSource></asp:Content>
MyAds.aspx.vb
Imports System
Imports System.Web.UI.WebControls
Imports AspNet.StarterKits.Classifieds.BusinessLogicLayer
Partial Class MyAds_aspx
Inherits System.Web.UI.Page
Protected Sub CurrentAdsGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim adId As Integer = Convert.ToInt32(e.CommandArgument)
AdsDB.ExpireAd(adId, Profile.MemberId)
InactiveAdsGrid.DataBind()
CurrentAdsGrid.DataBind()
End Sub
Protected Sub PendingAds_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Dim inactiveAds As AdsDataComponent.AdsDataTable = CType(e.ReturnValue, AdsDataComponent.AdsDataTable)
If Not (inactiveAds Is Nothing) AndAlso inactiveAds.Rows.Count > 0 Then
ActivationAdsPanel.Visible = True
Else
ActivationAdsPanel.Visible = False
End If
End Sub
Protected Sub CurrentAdsGrid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim UnlistButton As LinkButton = CType(e.Row.FindControl("UnlistButton"), LinkButton)
If Not (UnlistButton Is Nothing) Then '
UnlistButton.Attributes.Add("onclick", "return confirm('Please confirm that you are unlisting this ad. It will no longer appear among the active listings.')")
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Showing / Hiding "Action" columns for Ads based on site settings
Dim settings As SiteSettings = SiteSettings.GetSharedSettings()
' Allow users to edit ads:
ActivationAdsGrid.Columns(0).Visible = settings.AllowUsersToEditAds
' if user can edit, a link to EditAd is shown
ActivationAdsGrid.Columns(1).Visible = Not settings.AllowUsersToEditAds
' otherwise, the second column (ShowAd link) appears
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 3)).Visible = settings.AllowUsersToEditAds
' Allow users to upload photos:
ActivationAdsGrid.Columns((ActivationAdsGrid.Columns.Count - 1)).Visible = settings.AllowImageUploads
CurrentAdsGrid.Columns((CurrentAdsGrid.Columns.Count - 2)).Visible = settings.AllowImageUploads
If Not Page.IsPostBack Then
ActivationAdsButtonPanel.Visible = settings.AdActivationRequired
If Not (Request.QueryString("saved") Is Nothing) Then
MyAdsMultiView.SetActiveView(SavedAdsView)
End If '
End If
End Sub
Protected Sub CurrentAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserAdsView)
End Sub
Protected Sub InactiveAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserInactiveAdsView)
End Sub
Protected Sub SavedAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(SavedAdsView)
End Sub
Protected Sub ActivationAdsButton_Click(ByVal sender As Object, ByVal e As EventArgs)
MyAdsMultiView.SetActiveView(UserPendingAdsView)
Page.SetFocus(ActivationAdsGrid)
End Sub
End Class
voodoo9055
Participant
1873 Points
438 Posts
Re: The code does not work
Sep 26, 2006 08:01 PM|LINK
Profile is not getting set. MyAds.aspx is pulling the first user's information only. Any additional users will also see the Ads of the first user. I ran some debug code and the MemberId is not getting set for my SelectParameter for any of the objectdatasources on the MyAds.aspx page.
Profile ObjectDataSource parameters
karasakal
Member
81 Points
30 Posts
Re: A New Bug Found today.
Nov 05, 2006 01:35 AM|LINK
Dear Marcgel,
Is it possible, disallowing the upload mechanism for the photo's at the same time too? The users can not edit now, but they are already able to send "abuse" photo's to their existing ads without Approval of Administrator.
Thanks for your Help..
karasakal
marcgel
Member
405 Points
76 Posts
Microsoft
Re: A New Bug Found today.
Nov 09, 2006 04:39 PM|LINK
If you want you can. In the Page_Load of the MyAds page there is a line:
CurrentAdsGrid.Columns[CurrentAdsGrid.Columns.Count - 2].Visible = settings.AllowImageUploads
that determines if the Photos link gets shown. It is keyed off of the setting AllowImageUploads. You could do
CurrentAdsGrid.Columns[CurrentAdsGrid.Columns.Count - 2].Visible = settings.AllowUsersToEditAds
and key if off of the edit setting. Not sure how that would affect other things. But give it a try.
ASPMAN55
Member
12 Points
3 Posts
Re: Email Notification Bug
Nov 10, 2006 07:16 PM|LINK
This fix is for the older "beta" version only. For the latest version (the "final" version with a digital signature date of August 2006) the first change you listed has been done already. The second one still needs to be done. In addition, there is a NEW bug that needs to be fixed. It is NOT in the first version, however somehow it shows up in the newer version. It is a change necessary to allow the Email Notification Link that is sent to the administrator to work correctly.
App_Code -> BLL -> Maintenance.vb (Line 70) change from:
messageBody.AppendFormat(
"EditAd.aspx?id={0}", ad.Id)TO:
messageBody.AppendFormat(
"/EditAd.aspx?id={0}", ad.Id)This will now send the proper link via the Admin email.
ASPMAN55