0

Hi During my Web browser program i have got a bookmarks bar running but when ever i add a bookmark to it the name is the URL, which is bad if you are adding a Google search page. When i try and add document title into the equation apparently i can't because the constructor does not take more thank 5 arguments. Here is my code so far.

private void toolStripButton9_Click(object sender, EventArgs e)
        {
            if (getCurrentBrowser().Url != null)
                addLink(getCurrentBrowser().Url.ToString(), getCurrentBrowser().Url.ToString());
        } // code for Add to bookmarks bar /|\

Addlink below \|/

private void addLink(String url, string name)
        {
            XmlDocument myXml = new XmlDocument();
            XmlElement el = myXml.CreateElement("link");
            el.SetAttribute("url", url);
            el.InnerText = name;

            if (!File.Exists(linksXml))
            {
                XmlElement root = myXml.CreateElement("links");
                myXml.AppendChild(root);
                root.AppendChild(el);
            }
            else
            {
                myXml.Load(linksXml);
                myXml.DocumentElement.AppendChild(el);
            }
            if (linkBar.Visible == true)
            {
                ToolStripButton b =
                          new ToolStripButton(el.InnerText, getFavicon(url), items_Click, el.GetAttribute("url"));
                b.ToolTipText = el.GetAttribute("url");
                
                b.MouseUp += new MouseEventHandler(b_MouseUp);
                linkBar.Items.Add(b);
            }

            if (favoritesPanel.Visible == true)
            {
                TreeNode node = new TreeNode(el.InnerText, faviconIndex(url), faviconIndex(el.GetAttribute("url")));
                node.Name = el.GetAttribute("url");
                node.ToolTipText = el.GetAttribute("url");
                node.ContextMenuStrip = linkContextMenu;
                favTreeView.Nodes[0].Nodes.Add(node);
            }
            myXml.Save(linksXml);
        }

this is the bit i think i need to focus on.

if (linkBar.Visible == true)
            {
                ToolStripButton b =
                          new ToolStripButton(el.InnerText, getFavicon(url), items_Click, el.GetAttribute("url"));
               
 b.ToolTipText = el.GetAttribute("url");
                
                b.MouseUp += new MouseEventHandler(b_MouseUp);
                linkBar.Items.Add(b);
            }

i think i need to add a new attribute. if i was i would call it name but when i try and add a new attribute it does not work. apparently i cannot have a constructor that takes 5 arguments. also in this area i think i need to add something,

private void toolStripButton9_Click(object sender, EventArgs e)
        {
            if (getCurrentBrowser().Url != null)
                addLink(getCurrentBrowser().Url.ToString(), getCurrentBrowser().Url.ToString());
        }

i think i need to add another getCurrentBrowser().DocumentTitle.ToString(); but i am not sure.

I have an idea of what needs done but i just need some help to accomplish it. But basically i want when the user adds a bookmark that the document title is shown not the URL because if you bookmarked a Google search it would be a huge bookmark.

Any help is much appreciated

NSSLTD

Edited by nssltd: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by nssltd
0

I have found the solution it was as simple as this.

private void toolStripButton9_Click(object sender, EventArgs e)
        {
            if (getCurrentBrowser().Url != null)
                addLink(getCurrentBrowser().Url.ToString(), getCurrentBrowser().DocumentTitle.ToString());
        }

I hope this could of help anyone!

NSSLTD

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.