Hey Woofmeister, this is a long shot, but are you logged in as an admin that you created via the asp.net configuration (rather than a user that was created through the club site create user wizard)?
If you create a user via the config tool, then the site's database doesn't know about that user, has no entry for them, and thus can't update them. Try creating a new user via the membership registration thingy, then use the cofig tool to make them an admin.
I was logged on in the manner you described. I took your suggestion and it worked. I'm grateful. Thanks MrLunch. and to all others who took interest in my plight.
Thanks Bugslayer! tried it worked. I'm new to this, but thanks to contributors like yourself I'm learning and getting ever closer to being able to lend some input of my own. I noticed after implementing your fix that I landed at /Events_view.aspx?EventID=
which is great except my links to previous and next don't work. Which is not surprising, I'm having the same problem with previous and next location links, I'm just started working on it with little success but I'll keep pluggin away somethings gotta give.
As U reported, after hitting Cancel, the page indeed landed at List View of events with
/Events_view.aspx?EventID= (which looks so lame and abrupt) in the IE address bar. But the page displayed the 1st event, and surprisingly I was able to navigate to NEXT events (not previous events, as there were
none, although for some reason the link remained enabled the 1st time).
Overall how many Events have U created in your App? Just trying to simulate your scenario.
Thanx
"Our truest life is when we are in dreams awake." - Henry David Thoreau
Hey Bugslayer, I have 3 events all were pending. 1 April, 1 May, 1 June. Same goes with the locations list as they're tied to the three different events. I'll create some previous events and see what happens.
Be sure to use VB as the language if that is what you have. The second problem, with event wireup, is associated with the next/previous buttons. I believe the original code, almost at the bottom of the file, is like so:
I totally rewrote the News/Announcements Paging code, just did not seem to work properly and sometimes it is better to just redo something as opposed to deconstruct someone else's spaghetti.
I have not tried creating more than 10 events for the List all events to see if the Paging code works, I suspect you will encounter the same problems.
Angelo, maybe you are talking about News_View.aspx? This is the page where you view a single news item and you can click next or previous to navigate among them all. It is different than News_list.aspx (or the similar Locations_List.aspx)
that I mentioned above. The *_list.aspx pages just list a "page worth" of news or events or locations. And you can go to the next page, etc. The problem I found there was pretty simple. The problems I found in *_View.aspx were more subtle.
For News_View.aspx, I too noticed that the next/previous links were just not working. a Next or Prev link would be active when it shouldn't be (eg, a previous link was active for the very first news item, or a next link for
the very last). Clicking on these invalid links would refresh the page, display the same (first or last) news item (or location, or event), but the link would then be (properly) not enabled. Anyway it was broken, and the behavior was confusing.
I tried tweaking it a little bit, but as you say, sometimes it is better to just redo. So I fixed the next/previous logic for News_View.aspx and Event_View.aspx, and re-factored the result. I tried it with more than 3 pages
worth of news and events and it is working nicely. Cleaner, too. As I said, this problem and fix is totally independent of the next/prev problem that I found in Locations_List.aspx, which was apparently just a sloppy cut-n-paste.
I don't know if this (next/prev broken in News_View.aspx) is a previously-mentioned problem or not, but anyway, enclosed below is my code for a corrected News_View.aspx. It employs a private class for tracking the previous
and next items of an article. To me it is cleaner and clearer. There are a couple other, independent changes in this code you should be aware of, if you want to use it:
(1) I added a little method (CanEdit) to turn the Edit button on or off, depending on the identity of the user. Only the original poster can update a news item. This requires a change to the DB Schema for the Announcements/News
table; I added a postedBy varchar field, and I retrieve it in the query. If you don't want that feature, then just remove mention of the CanEdit() in code and in the markup, remove the retrieval of the postedBy column in the query, and remove the text that
says "last posted by" in the panel.
(2) There is a call to a new method GetStatusMessage() which just references a Session variable and returns its contents. I inserted that to track "silent failures" that the club site sometimes exhibits (eg, doesn't update the
DB, but doesn't tell you). You can just yank that part, or implement your own.
(3) I changed the name of the table from announcements to News. This is gratuitous. To undo that change, just search/replace news for announcements in all the queries.
Those are the only "other" changes I can recall making in this aspx. Anyway, here is the new code to fix the paging. (sorry no VB)
MrLunch
Member
727 Points
144 Posts
Re: Unable to update Email field
Apr 14, 2006 11:06 PM|LINK
Hey Woofmeister, this is a long shot, but are you logged in as an admin that you created via the asp.net configuration (rather than a user that was created through the club site create user wizard)?
If you create a user via the config tool, then the site's database doesn't know about that user, has no entry for them, and thus can't update them. Try creating a new user via the membership registration thingy, then use the cofig tool to make them an admin.
Forums Starter Kit
Woofmeister
Member
20 Points
4 Posts
Re: Unable to update Email field
Apr 15, 2006 03:50 PM|LINK
Good Call.
You hit the nail on the head.
I was logged on in the manner you described. I took your suggestion and it worked. I'm grateful. Thanks MrLunch. and to all others who took interest in my plight.
Keep up the good work.
Rick(Newbie)
BugSlayer
Member
246 Points
58 Posts
Bug#5 Error on Cancelling out of Create new event
Apr 17, 2006 06:14 PM|LINK
Bug# 5
How to simulate:
Log in as the admin of the Club Website.
Click on Events
Click on Add new Event
Do not add/modify anything on the Ad new Event page, and directly hit 'Cancel'
Application errors out
Fix 5.1
In file Events_view.aspx scroll to the code for Get/Set of Property EventId
Before every CInt(id) operation id is being checked via If Not id Is Nothing Then
Replace this check by If Not id Is Nothing And IsNumeric(Id) Then
in two places within this property block..
Save changes and try simulating again.
As always... a better, more elegant fix is always welcome !
Thanks.
Dravend
Member
77 Points
16 Posts
Re: Bug#5 Error on Cancelling out of Create new event
Apr 18, 2006 12:22 AM|LINK
Thanks Bugslayer! tried it worked. I'm new to this, but thanks to contributors like yourself I'm learning and getting ever closer to being able to lend some input of my own. I noticed after implementing your fix that I landed at /Events_view.aspx?EventID= which is great except my links to previous and next don't work. Which is not surprising, I'm having the same problem with previous and next location links, I'm just started working on it with little success but I'll keep pluggin away somethings gotta give.
Keep on posting! Dravend
BugSlayer
Member
246 Points
58 Posts
Re: Bug#5 Error on Cancelling out of Create new event
Apr 18, 2006 02:37 PM|LINK
Hi Dravend,
Good catch dude ! Thanx for the Input.
As U reported, after hitting Cancel, the page indeed landed at List View of events with /Events_view.aspx?EventID= (which looks so lame and abrupt) in the IE address bar. But the page displayed the 1st event, and surprisingly I was able to navigate to NEXT events (not previous events, as there were none, although for some reason the link remained enabled the 1st time).
Overall how many Events have U created in your App? Just trying to simulate your scenario.
Thanx
Dravend
Member
77 Points
16 Posts
Re: Bug#5 Error on Cancelling out of Create new event
Apr 18, 2006 05:12 PM|LINK
Hey Bugslayer, I have 3 events all were pending. 1 April, 1 May, 1 June. Same goes with the locations list as they're tied to the three different events. I'll create some previous events and see what happens.
Thanks, Dravend
cheeso
Member
342 Points
75 Posts
Re: locations_list.aspx bad event wireup
Apr 19, 2006 03:43 AM|LINK
Locations_list.aspx has incorrect event wireup. and a bad title.
The original title in my version of the file was "News Items". This can be fixed at the top of the page with this:
<div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Locations" Trace="false" %>
</div>Be sure to use VB as the language if that is what you have. The second problem, with event wireup, is associated with the next/previous buttons. I believe the original code, almost at the bottom of the file, is like so:
<div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><Club:PageNumberer ID="pn2" runat="server" DisplayedPages="7"
CssClass="PageNumbers"
OnSelectedPageChanged="pn1_SelectedPageChanged" />
</div>And what you reall want is for the pn2_SelectedPageChanged method to be tickled, like so:
<div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><Club:PageNumberer ID="pn2" runat="server" DisplayedPages="7"
CssClass="PageNumbers"
OnSelectedPageChanged="pn2_SelectedPageChanged" />
</div>Of course, for the previous PageNumberer, the one with id="pn1", you want pn1_SelectedPageChanged. Looks like a simple copy/paste error.
-Cheeso
aabruzzese
Contributor
2806 Points
759 Posts
Re: locations_list.aspx bad event wireup
Apr 19, 2006 02:00 PM|LINK
I totally rewrote the News/Announcements Paging code, just did not seem to work properly and sometimes it is better to just redo something as opposed to deconstruct someone else's spaghetti.
I have not tried creating more than 10 events for the List all events to see if the Paging code works, I suspect you will encounter the same problems.
cheeso
Member
342 Points
75 Posts
Re: locations_list.aspx bad event wireup
Apr 19, 2006 03:00 PM|LINK
Angelo, maybe you are talking about News_View.aspx? This is the page where you view a single news item and you can click next or previous to navigate among them all. It is different than News_list.aspx (or the similar Locations_List.aspx) that I mentioned above. The *_list.aspx pages just list a "page worth" of news or events or locations. And you can go to the next page, etc. The problem I found there was pretty simple. The problems I found in *_View.aspx were more subtle.
For News_View.aspx, I too noticed that the next/previous links were just not working. a Next or Prev link would be active when it shouldn't be (eg, a previous link was active for the very first news item, or a next link for the very last). Clicking on these invalid links would refresh the page, display the same (first or last) news item (or location, or event), but the link would then be (properly) not enabled. Anyway it was broken, and the behavior was confusing.
I tried tweaking it a little bit, but as you say, sometimes it is better to just redo. So I fixed the next/previous logic for News_View.aspx and Event_View.aspx, and re-factored the result. I tried it with more than 3 pages worth of news and events and it is working nicely. Cleaner, too. As I said, this problem and fix is totally independent of the next/prev problem that I found in Locations_List.aspx, which was apparently just a sloppy cut-n-paste.
I don't know if this (next/prev broken in News_View.aspx) is a previously-mentioned problem or not, but anyway, enclosed below is my code for a corrected News_View.aspx. It employs a private class for tracking the previous and next items of an article. To me it is cleaner and clearer. There are a couple other, independent changes in this code you should be aware of, if you want to use it:
(1) I added a little method (CanEdit) to turn the Edit button on or off, depending on the identity of the user. Only the original poster can update a news item. This requires a change to the DB Schema for the Announcements/News table; I added a postedBy varchar field, and I retrieve it in the query. If you don't want that feature, then just remove mention of the CanEdit() in code and in the markup, remove the retrieval of the postedBy column in the query, and remove the text that says "last posted by" in the panel.
(2) There is a call to a new method GetStatusMessage() which just references a Session variable and returns its contents. I inserted that to track "silent failures" that the club site sometimes exhibits (eg, doesn't update the DB, but doesn't tell you). You can just yank that part, or implement your own.
(3) I changed the name of the table from announcements to News. This is gratuitous. To undo that change, just search/replace news for announcements in all the queries.
Those are the only "other" changes I can recall making in this aspx. Anyway, here is the new code to fix the paging. (sorry no VB)
<div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Untitled Page" Trace="false"%>
<%@ Register TagPrefix="Club" Namespace="ClubSite" %>
<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="LoginBanner.ascx" %>
<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="ImageThumbnail.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
private class NextPrev
{
public int nextArticleId;
public int prevArticleId;
public NextPrev() { nextArticleId = INVALIDID; prevArticleId = INVALIDID; }
}
private NextPrev pointers;
const int INVALIDID = -1;
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
Trace.Write("Not Post Back");
InitDatasources();
EnableLinksIntelligently();
}
}
protected void FormView1_DataBound(object sender, System.EventArgs e)
{
DataRowView view = (DataRowView)(FormView1.DataItem);
if (view == null) Response.Redirect("Default.aspx");
object o = view["staticURL"];
if (o != null && o !=DBNull.Value)
{
string staticurl = (string)o;
if (staticurl != "")
{
Response.Redirect(staticurl);
}
}
}
protected void nextButton_Click(object sender, System.EventArgs e)
{
NextPrev np1 = GetNextPrev(ArticleID);
if (np1.nextArticleId != INVALIDID)
{
ArticleID = np1.nextArticleId;
InitDatasources();
}
EnableLinksIntelligently();
}
protected void prevButton_Click(object sender, System.EventArgs e)
{
Trace.Write("Previous");
NextPrev np1= GetNextPrev(ArticleID);
if (np1.prevArticleId != INVALIDID)
{
ArticleID = np1.prevArticleId;
InitDatasources();
}
EnableLinksIntelligently();
}
void InitDatasources()
{
PhotoPanel.Visible = true;
SqlDataSource1.SelectParameters["id"].DefaultValue = System.Convert.ToString(ArticleID);
SqlDataSource2.SelectParameters["id"].DefaultValue = System.Convert.ToString(ArticleID);
}
void EnableLinksIntelligently()
{
pointers = GetNextPrev(ArticleID);
Trace.Write(String.Format("New links: curr={0} next={1} prev={2}", ArticleID, pointers.nextArticleId, pointers.prevArticleId));
LinkButton1.Enabled = //(pointers.nextArticleId != INVALIDID);
LinkButton3.Enabled = (pointers.nextArticleId != INVALIDID);
LinkButton2.Enabled = //(pointers.prevArticleId != INVALIDID);
LinkButton4.Enabled = (pointers.prevArticleId != INVALIDID);
}
protected bool CanEdit(string postedBy)
{
MembershipUser user = Membership.GetUser();
return (User.IsInRole("Administrators") && (postedBy == user.UserName));
}
int ArticleID
{
get
{
int m_articleID;
object id = ViewState["ArticleId"];
if (id != null)
{
m_articleID = System.Convert.ToInt32(id);
}
else
{
id = Request.QueryString["ArticleId"];
if (id != null)
{
m_articleID = System.Convert.ToInt32(id);
}
else
{
m_articleID = 1;
}
ViewState["ArticleId"] = m_articleID;
}
return m_articleID;
}
set
{
ViewState["ArticleId"] = value;
}
}
NextPrev GetNextPrev (int ArticleID)
{
NextPrev np = new NextPrev();
try
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ClubSiteDB"].ConnectionString);
SqlCommand command = new SqlCommand("NextPrevAnnouncement", connection);
SqlParameter param0 = new SqlParameter("@id", ArticleID);
SqlParameter param1 = new SqlParameter("@previd", INVALIDID);
SqlParameter param2 = new SqlParameter("@nextid", INVALIDID);
param1.Direction = ParameterDirection.InputOutput;
param2.Direction = ParameterDirection.InputOutput;
command.Parameters.Add(param0);
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
command.ExecuteNonQuery();
if (param1.Value != null && param1.Value != DBNull.Value)
{
np.prevArticleId = Convert.ToInt32(param1.Value);
}
else
{
np.prevArticleId = INVALIDID;
}
if (param2.Value != null && param2.Value != DBNull.Value)
{
np.nextArticleId= Convert.ToInt32(param2.Value);
}
else
{
np.nextArticleId = INVALIDID;
}
connection.Close();
}
catch (Exception e1)
{
Trace.Write(String.Format("Exception while getting next/prev news: {0}", e1.Message));
np = new NextPrev();
}
return np;
}
protected void SqlDataSource2_Selected(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
{
PhotoPanel.Visible = (e.AffectedRows != 0);
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="body">
<Club:LoginBanner ID="LoginBanner1" runat="server" />
<!--
Left column
-->
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>
News </h2>
<p>
Here you'll find news items the club
finds noteworthy.<br />
<%= SharedRoutines.GetStatusMessage() %>
</p>
</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsiteDB %>"
SelectCommand="SELECT images.id, images.album, images.title FROM images, News WHERE images.album=News.albumid AND News.id=@id"
OnSelected="SqlDataSource2_Selected">
<SelectParameters>
<asp:Parameter Type="Int32" DefaultValue="1" Name="id"></asp:Parameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:Panel ID="PhotoPanel" runat="server" CssClass="leftblock">
<h2>
Associated Album photos</h2>
<asp:DataList ID="DataList2" runat="server" DataSourceID="SqlDataSource2" DataKeyField="id"
RepeatColumns="2" CellSpacing="2" SelectedIndex="0" ItemStyle-CssClass="unselected">
<ItemTemplate>
<a href='photoalbum_contents.aspx?Albumid=<%#Eval("album") %>'>
<asp:Image ID="Image1" ImageUrl='<%# "imagefetch.ashx?size=1&imageid=" + Convert.ToString(Eval("id")) %>'
runat="server" /><br />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</a>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
</div>
<!--
Right column
-->
<div id="columnright">
<div class="rightblock">
<a href="news_list.aspx">News Article List</a></div>
<div class="rightblock">
<div class="nextlink">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="nextButton_Click">Next Article »</asp:LinkButton>
</div>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="prevButton_Click">« Previous article</asp:LinkButton>
<div class="dashedline">
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"
SelectCommand="SELECT id, itemdate, title, description, photo, albumid, staticURL, postedBy FROM News WHERE (id = @id)">
<SelectParameters>
<asp:Parameter Type="Int32" DefaultValue="1" Name="id"></asp:Parameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id"
Width="444px" OnDataBound="FormView1_DataBound">
<ItemTemplate>
<h2>
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<p>
<asp:Label Text='<%# Eval("itemdate","{0:D}") %>' runat="server" ID="itemdateLabel" />
</p>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<asp:Panel ID="panel3" runat="server" Visible='<%# Eval("postedBy").ToString()!="" %>'>
<p>
(last updated by
<asp:Label ID="postedByLabel" runat="server" Text='<%# SharedRoutines.truncate(Eval("postedBy").ToString()) %>' />)
</p>
</asp:Panel>
<asp:Panel runat="server" ID="panel1" CssClass="actionbuttons" Visible='<%# CanEdit(Eval("postedBy").ToString()) %>'>
<Club:RolloverLink ID="editbtn" runat="server" Text="Edit Article" NavigateURL='<%# "news_edit.aspx?ArticleID=" + Convert.ToString( ArticleID )%>' />
</asp:Panel>
</ItemTemplate>
</asp:FormView>
<div class="dashedline">
</div>
<div class="nextlink">
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="nextButton_Click">Next Article »</asp:LinkButton>
</div>
<asp:LinkButton ID="LinkButton4" runat="server" OnClick="prevButton_Click">« Previous Article</asp:LinkButton>
</div>
</div>
<div class="clear2column">
</div>
</div>
</asp:Content>
</div>BugSlayer
Member
246 Points
58 Posts
Bug #6 Erratic Prev/Next links in News_view
Apr 20, 2006 02:39 PM|LINK
Excellent work cheeso ![8-|]
Thanks a bunch, for sharing your findings and fixes.[:D]
By the power vested in me by the Senate [;)] , I hereby declare your reported bug and the associated fix as Bug # 6 & Fix 6.1 respectively.
Keep 'em coming dude... guns blazing !!!