Jump to content
Xtreme .Net Talk

fizzled

Avatar/Signature
  • Posts

    52
  • Joined

  • Last visited

About fizzled

  • Birthday July 18

Personal Information

  • Visual Studio .NET Version
    None
  • .NET Preferred Language
    C#

fizzled's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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?
  2. 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.
  3. Have you tried it without the <script> elements in the .js file?
  4. Try the OnLoad() event Try using the OnLoad event in the body tag of your html. <body OnLoad="showIFrame()">
  5. 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>
  6. I'm not using codebehind for one thing. And if you mean does FBB.ForumLink work: no, it doesn't.
  7. I have the following at the top of my page: <%@ Register TagPrefix="FBB" TagName="ForumLink" src="ForumLink.ascx" %>
  8. 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?
  9. 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>
  10. 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.
  11. 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/>"; }
  12. 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
  13. fizzled

    C# Smtp

    Don't know if this is the issue, but found this possible solution through Google.
  14. Seems pretty straightforward to me. Have you tried it?
  15. 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:
×
×
  • Create New...