
fizzled
Avatar/Signature-
Posts
52 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by fizzled
-
Confused by MSDN Example for HttpCookie.HasKeys Property On the MSDN entry for the System.Web.HttpCookie.HasKeys Property, the example says it will populate two string arrays: one with the value names (the keys) in the cookie, and one with the corresponding values. However, on looking at the code, it seems to me all it is doing is populating both string arrays with the value names. Am I missing something?
-
Differences From what I've read, the main reasons for using DIV layouts are: DIVs usually require less code DIV layouts usually display faster Using a DIV layout can require less code depending on how much and what type of CSS you are using. Less code will also mean smaller file sizes. A DIV layout will also usually display faster because it should display as it is received from the server, whereas tables aren't displayed until the entire table is received. Of course, for smaller tables this may not make a difference. For newer Web developers, tables can be easier to implement, because they will require less, if any, CSS styling to control the layout, whereas DIV layouts require CSS to really be useful.
-
Have you tried it without the <script> elements in the .js file?
-
Try the OnLoad() event Try using the OnLoad event in the body tag of your html. <body OnLoad="showIFrame()">
-
The two files I'm using are: ViewBoard.ascx: <%@ Control Language="C#" Debug="True" AutoEventWireup="True" %> <%@ Register TagPrefix="FBB" TagName="ForumLink" src="ForumLink.ascx" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <script runat="server"> public String DBConnString = ""; private void Page_Load (Object Sender, EventArgs e) { if (!Page.IsPostBack) { LoadForumList(); } } private void LoadForumList () { String qryForumGroups = "SELECT ForumGroupID, Title, Description FROM ForumGroups ORDER BY ListPosition ASC, Title ASC;"; // try { OleDbConnection fbbConn = new OleDbConnection(DBConnString); OleDbCommand fbbCmd = new OleDbCommand(qryForumGroups, fbbConn); OleDbDataReader rdrData; if ((DBConnString == null) || (DBConnString.Length == 0)) { throw new Exception("No Connection String specified."); } fbbConn.Open(); rdrData = fbbCmd.ExecuteReader(); if (rdrData.HasRows) { rptrForumList.Visible = true; rptrForumList.DataSource = rdrData; rptrForumList.DataBind(); } else { litDebug.Visible = true; litDebug.Text = "No Forum Groups."; } rdrData.Close(); rdrData = null; fbbCmd = null; fbbConn.Close(); fbbConn = null; /* } catch (OleDbException dbEx) { litDebug.Visible = true; litDebug.Text = dbEx.Message; } catch (Exception ex) { litDebug.Visible = true; litDebug.Text = ex.Message; } */ } private void rptrForumList_ItemDataBound (Object Sender, RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Item: case ListItemType.AlternatingItem: ((ForumLink) e.Item.FindControl("lnkForum")).ForumDataRowView = (DataRowView) e.Item.DataItem; break; } } // End lnkViewForum_Command </script> <div class="divPageContent"> <div class="divMenuBar"> </div> <ASP:Literal ID="litDebug" Visible="false" RunAt="server" /> <ASP:Repeater ID="rptrForumList" Visible="false" OnItemDataBound="rptrForumList_ItemDataBound" RunAt="server"> <HeaderTemplate> <div class="divForum"> </HeaderTemplate> <ItemTemplate> <FBB:ForumLink ID="lnkForum" RunAt="server" /> </ItemTemplate> <FooterTemplate> </div> </FooterTemplate> </ASP:Repeater> </div> ForumLink.ascx: <%@ Control Language="C#" Debug="True" %> <%@ Import Namespace="System.Data" %> <script runat="server"> public DataRowView ForumDataRowView; private void Page_Load (Object Sender, EventArgs e) { lnkViewForum.Text = ForumDataRowView["Title"].ToString(); lnkViewForum.CommandArgument = ForumDataRowView["ForumGroupID"].ToString(); } private void lnkViewForum_Command (Object Sender, CommandEventArgs e) { Session["CurrentForum"] = e.CommandArgument.ToString(); Response.Redirect("ViewForum.aspx"); } // End lnkViewForum_Command </script> <div class="divForum" id="Forum<%# ((DataRowView) ForumDataRowView)["ForumGroupID"].ToString() %>"> <div class="divForumName" id="Forum<%# ((DataRowView) ForumDataRowView)["ForumGroupID"].ToString() %>_Name"> <ASP:LinkButton ID="lnkViewForum" CommandName="ViewForum" OnCommand="lnkViewForum_Command" RunAt="server" /> </div> <div class="divForumDescription" id="Forum<%# ((DataRowView) ForumDataRowView)["ForumGroupID"].ToString() %>_Desc"> <%# ((DataRowView) ForumDataRowView)["Description"].ToString() %> </div> </div>
-
I'm not using codebehind for one thing. And if you mean does FBB.ForumLink work: no, it doesn't.
-
I have the following at the top of my page: <%@ Register TagPrefix="FBB" TagName="ForumLink" src="ForumLink.ascx" %>
-
I am working on a small forum project for the sake of learning. At the moment, I'm using a Repeater to list Forums, and a custom control named ForumLink to actually create a link to each forum. Within ForumLink is simply a LinkButton with some additional formatting. Within the Repeater's OnItemDataBound method I am trying to pass the current DataItem as a DataRowView to a public property of ForumLink, ForumDataRowView, so that I can customize the display of the LinkButton. To set properties of standard controls, I'd simply use the FindControl() method, but I'm having trouble casting to my custom control. /* Produces the error: CS0246: The type or namespace name 'ForumLink' could not be found (are you missing a using directive or an assembly reference?) */ ((ForumLink) e.Item.FindControl("lnkForum")).ForumDataRowView = (DataRowView) e.Item.DataItem; Anyone know where I'm going wrong?
-
Try using the CssClass property of the ASP TextBox control: <ASP:TextBox ID="Text1" CssClass="controls" RunAt="server" /> As for <span> vs <div>, I use <div> to format general sections of my pages, and <span> for more specific fine-tuning (mostly of short text segments). For example: <html> <head> <title>Book List</title> <style type="text/css"> .divBookList { margin: 10px; border: 1px solid #000; background-color: #ccf; width: 500px; padding: 10px; } .divBook { font-family: Arial, sans-serif; font-size: 12pt; margin: 5px 0; padding: 2px 5px; color: #000; background-color: #fff; } .spanBookTitle { font-weight: bold; text-decoration: underline; } .spanBookAuthor { font-style: italic; color: #c00; } </style> </head> <body> <div class="divBookList"> <div class="divBook"> <span class="spanBookTitle">Some Book</span>, by <span class="spanBookAuthor">Some Author</span> </div> </div> </body> </html>
-
lstJobs must have an initial value selected, as the contents of lstWeaponClasses is dependent upon the current value of lstJobs. For the form to be displayed properly when the user first visits the page, I must programmatically select one of the items in lstJobs. There may be other ways of doing this; this just seemed to make the most sense to me at the time.
-
Well, I seem to have figured it out. Simply databinding a ListBox doesn't initialize the SelectedValue to the value of the first item in the ListBox, so I modified the LoadJobList method: if (rdrJobs.HasRows) { lstJobs.DataSource = rdrJobs; lstJobs.DataTextField = "JobName"; lstJobs.DataValueField = "JobID"; lstJobs.DataBind(); [color=green]lstJobs.SelectedIndex = 0;[/color] } else { strErrors += "Could not load Job list from database.<br/>"; }
-
The code at the end of this post produces the error "Input string was not in a correct format" on the line with: LoadWeaponList(Convert.ToInt32(lstJobs.SelectedValue)); If I remove the Convert.ToInt32() method, the code will produce a compilation error saying "The best overloaded method match for 'ASP.rostatcalc_aspx.LoadWeapon(int)' has some invalid arguments". I've checked the HTML produced by this template with the offending lines commented out and all the listbox values contain numbers, so I'm at a loss as to why this function call refuses to accept the input. Does anyone here know? private String strConnString; private String strErrors; public ROCharacter objCharacter; public void Page_Load (Object Sender, EventArgs e) { strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("data/firo.mdb") + ";"; strErrors = ""; if (!Page.IsPostBack) { objCharacter = new ROCharacter(); objCharacter.ConnString = strConnString; LoadJobList(); LoadWeaponList(Convert.ToInt32(lstJobs.SelectedValue)); } DisplayCharacterInformation(); } // End Page_Load private void LoadJobList () { String qryJobList = "SELECT JobID, JobName FROM Jobs ORDER BY JobName ASC;"; OleDbConnection cnJobs = new OleDbConnection(strConnString); OleDbCommand cmdJobs = new OleDbCommand(qryJobList, cnJobs); OleDbDataReader rdrJobs; cnJobs.Open(); rdrJobs = cmdJobs.ExecuteReader(); if (rdrJobs.HasRows) { lstJobs.DataSource = rdrJobs; lstJobs.DataTextField = "JobName"; lstJobs.DataValueField = "JobID"; lstJobs.DataBind(); } else { strErrors += "Could not load Job list from database.<br/>"; } rdrJobs.Close(); rdrJobs = null; cmdJobs = null; cnJobs.Close(); cnJobs = null; } // End LoadJobList private void lstJobs_SelectedIndexChanged (Object Sender, EventArgs e) { /* User selected a new Job for their Character. */ // LoadWeaponList(lstJobs.SelectedValue); } // End lstJobs_SelectedIndexChanged private void LoadWeaponList (int iJob) { /* Load the Weapon Class list based on the specified Job. */ String qryWeapons = "SELECT JW.WeaponClassID, WC.WeaponClass FROM JobWeapons AS JW LEFT JOIN WeaponClasses AS WC ON JW.WeaponClassID = WC.WeaponClassID WHERE JW.JobID = @JobID ORDER BY WC.WeaponClass;"; OleDbConnection cnWeapons = new OleDbConnection(strConnString); OleDbCommand cmdWeapons = new OleDbCommand(qryWeapons, cnWeapons); OleDbDataReader rdrWeapons; cmdWeapons.Parameters.Add(new OleDbParameter("JobID", OleDbType.Integer)).Value = lstJobs.SelectedValue; cnWeapons.Open(); rdrWeapons = cmdWeapons.ExecuteReader(); if (rdrWeapons.HasRows) { lstWeaponClasses.DataSource = rdrWeapons; lstWeaponClasses.DataTextField = "WeaponClass"; lstWeaponClasses.DataValueField = "WeaponClassID"; lstWeaponClasses.DataBind(); } else { strErrors += "Could not load Weapon Class list from database.<br/>"; } rdrWeapons.Close(); rdrWeapons = null; cmdWeapons = null; cnWeapons.Close(); cnWeapons = null; } // End LoadWeaponList
-
I don't know if this would work, but if you are using the .NET Framework v1.1, you could try ListBoxMaster.SelectedValue . Also, I noticed this on MSDN. On the ListControl.SelectedIndexChanged event description, it says: And under the Control.EnableViewState property:
-
How would I use nested, databound repeaters in conjunction with an Access database? I've seen examples with MSSQL, but that isn't really an option for me atm. I tried to use two SELECTS in a single query for my OleDbDataAdapter so I could then set up a relation between the two result tables, but Access apparently doesn't support that. Anyone have any ideas? Edit Nevermind, I found a site that used a slightly different approach from the site I'd previously visited. This second approach was just what I was looking for. If you're interested, its at Master-Detail Display using Nested Repeater Web Forms Control
-
Performance isn't really that big an issue right now, I was just wondering for future reference mainly. Thanks for the advice.
-
I currently have a table (in Access) to store information for articles such as Author, Headline, ArticleText, PostDateTime, etc. In addition to the regular information, these articles can also be considered Active or Archived, so I've tossed in a true/false IsActive field. Finally, I plan to let the author set an expiration date, ExpDate, for the articles, whereby the article will automatically be considered Archived if it is viewed after the expiration date. tblArticles: ArticleID (AutoNumber) Author (Text) Headline (Text) ArticleText (Memo) PostDateTime (Date/Time) IsActive (Yes/No, formatted to True/False) ExpDate (Date/Time) So my question is this: After looking at the table I've come up with, I'm suddenly wondering if the IsActive field is just a waste of space, albeit a small one. Anytime an author/administrator chose to archive an article, I could simply update the row's ExpDate with the current date (or the date of the previous day, depending how I coded it) and forgo the IsActive check. However, I was also thinking the SQL execution would probably be faster if all I'm checking is a boolean field when I'm retrieving Active or Archived articles, instead of having to compare the dates on every row. Does anyone have any thoughts, suggestions, or opinions?
-
With all the effort going into developing this website, I would think you could relatively easily create these item templates via the website as well (just save item templates in a separate database table from the actual item details, let the owners open their item templates, make minor changes specific to the new item, and Save As a new item detail), and forgo this whole extra program issue. Perhaps that doesn't help, but I do think the whole process has been made a lot more complicated than it needs to be.
-
-
"No value given for one or more required parameters."
fizzled replied to matt09524's topic in Database / XML / Reporting
Does it tell you what line is causing the error? -
I'm attempting to use the following code to conditionally drop a link inside a Repeater, and from what I've read everywhere, I should be able to cast the RepeaterItem.DataItem to a DataRowView to access the current row of information so I can decide if I need a link or not. Does anyone see why this isn't working? private void rptrActiveBlogs_ItemDataBound (object Sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { [color=red]DataRowView drvCurrent = (DataRowView) e.Item.DataItem;[/color] Literal litAuthor = (Literal) e.Item.FindControl("litBlogAuthor"); if (drvCurrent["AuthorEmail"].ToString().Length == 0) { litAuthor.Text = drvCurrent["AuthorName"].ToString(); } else { litAuthor.Text = "<a href=\"mailto:" + drvCurrent["AuthorEmail"].ToString() + "\" title=\"Contact " + drvCurrent["AuthorName"].ToString() + "\">" + drvCurrent["AuthorName"].ToString() + "</a>"; } } } The error occurs on the line in red. The error specifically says "Specified cast is not valid."
-
A user on another forum was able to resolve the problem. I had to open the database in Access, open the table in Design view, and change the Format of the Yes/No column to True/False.
-
Using a DataSet would probably be fine in my current project, since it is very small-scale, but I would rather do it the correct way. Everything I need to do with the resulting rows at the moment can be accomplished without the extra overhead of a DataSet.
-
That's true, I guess I hadn't thought the logic through well. Anyways, I streamlined it a bit, but the same error still occurs. The new code is as follows: public void Page_Load (object Sender, EventArgs e) { string qryActiveBlogs = "SELECT B.BlogID, B.BlogTitle, B.BlogPostDate, B.BlogText, U.PublicName AS AuthorName FROM Blogs AS B INNER JOIN BlogUsers AS U ON B.BlogAuthor = U.UserID WHERE B.BlogActive = @BlogActive"; OleDbConnection cnBlog = new OleDbConnection(Application.Contents["FBConnStr"].ToString()); OleDbCommand cmdBlog = new OleDbCommand(qryActiveBlogs, cnBlog); OleDbDataReader rdrBlog; cmdBlog.Parameters.Add(new OleDbParameter("@BlogActive", OleDbType.Boolean)); cmdBlog.Parameters["@BlogActive"].Value = true; cnBlog.Open(); [color=red]rdrBlog = cmdBlog.ExecuteReader();[/color] if (rdrBlog.HasRows) { rptrActiveBlogs.DataSource = rdrBlog; rptrActiveBlogs.DataBind(); rptrActiveBlogs.Visible = true; } else { litBlogEmpty.Visible = true; } rdrBlog.Close(); cnBlog.Close(); rdrBlog = null; cmdBlog = null; cnBlog = null; } The error still occurs on the red line "rdrBlog = cmdBlog.ExecuteReader();". I'm guessing the type mismatch is because cmdBlog.ExecuteReader() is not returning an OleDbDataReader object (?), but I'm not sure why that would happen. The only other thing I can think of is that I'm setting the boolean parameter incorrectly, but if so, I don't know how else to set it.