PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] HTML Editor Problem-VBForums
Results 1 to 20 of 20

Thread: [RESOLVED] HTML Editor Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Resolved [RESOLVED] HTML Editor Problem

    Well my HTML editor reads the text from the HTML file and puts it in a richtextbox, just like a text file, but when I read the file I loose the root directory of the file. Like if the image is in the root directory of the HTML file it would say that the image is in "/image.png" or whatever, but when I preview it in the webbrowser it loses all the images. My only idea to fix this is to save a temporary HTML file and then open it in the browser, rather than changing the source of the webpage to what I typed.

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,612

    Re: HTML Editor Problem

    Add this inside the HEAD section of your html page:

    Code:
    <base href="http://www.yourwebsite.com/" />
    The <base> tag specifies a default address or a default target for all links etc. on a page. So it will automatically add this part to the path, wherever required.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." Charles F. Kettering

    Read articles on My Blog 101 LINQ Samples JSON Validator XML Schema Validator "How Do I" videos on MSDN VB.NET and C# Comparison Good Coding Practices VBForums Reputation Saver String Enum Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    I dont think that that will work to good...

  4. #4
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,612

    Re: HTML Editor Problem

    Quote Originally Posted by reconrey View Post
    I dont think that that will work to good...
    Why so?

    That's what the <base> tag is meant for.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." Charles F. Kettering

    Read articles on My Blog 101 LINQ Samples JSON Validator XML Schema Validator "How Do I" videos on MSDN VB.NET and C# Comparison Good Coding Practices VBForums Reputation Saver String Enum Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    yea but if somebody uses my HTML editor to create a webpage that they wish to publish, they will then have to remove that code line...

  6. #6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    .......I am making my own.....

  8. #8
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: HTML Editor Problem

    Quote Originally Posted by reconrey View Post
    .......I am making my own.....
    No, really?

    I got that part, I was merely making a suggestion that in some cases, it doesn't pay to re-invent the wheel.

    Gary

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    ...i wanted to make one so I can add features to it that other HTML editors dont have...

  10. #10
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: HTML Editor Problem

    In which case, both of the samples that I linked to provide full source code, why not start with one of these as your base, and add the features that they are lacking.

    The reason I am saying this, is that they are likely to have overcome a lot of the early issues that you are going to face, leaving you to add the additionals features that you want.

    Gary

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    i already have the entire thing made from scratch...I just figured out that bug and I need a solution for it...

  12. #12
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,612

    Re: HTML Editor Problem

    Quote Originally Posted by reconrey View Post
    yea but if somebody uses my HTML editor to create a webpage that they wish to publish, they will then have to remove that code line...
    Handle that internally.
    When displaying in your editor, you put that tag. But while saving the file etc. you don't put that tag.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." Charles F. Kettering

    Read articles on My Blog 101 LINQ Samples JSON Validator XML Schema Validator "How Do I" videos on MSDN VB.NET and C# Comparison Good Coding Practices VBForums Reputation Saver String Enum Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    o man i luv u...

  14. #14
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: HTML Editor Problem

    It that your question answered?

    If so, remember to mark your thread resolved.

    Gary

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    ok...I cant figure out how to add that tag internally....

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    any ideas on how I would do this?

  17. #17
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: HTML Editor Problem

    Hey,

    You are going to need to help us to help you.

    Can you show some of the code that you are using to display the HTML in the WebBrowser?

    Gary

  18. #18
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,612

    Re: HTML Editor Problem

    This would be somewhat the logic you would need to go with.
    vb.net Code:
    1. Dim BaseTag as String
    2. Dim FileData as String
    3.  
    4. Sub LoadFile()   'or create file, whatever teh case maybe
    5.     BaseTag = String.Format("<base href=""{0}"" />", "http://www.yourwebsite.com/")
    6.     '... file load logic goes here...
    7.     FileData = FileData.Replace("</head>",  BaseTag & "</head>")
    8.     '... load the FileData in your webbrowser after this....
    9. End Sub
    10.  
    11. Sub SaveFile()
    12.     Dim textToSave As String = FileData.Replace(BaseTag, "")
    13.     '... logic to save file goes here...
    14. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." Charles F. Kettering

    Read articles on My Blog 101 LINQ Samples JSON Validator XML Schema Validator "How Do I" videos on MSDN VB.NET and C# Comparison Good Coding Practices VBForums Reputation Saver String Enum Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: HTML Editor Problem

    thanks man-i got it...

  20. #20
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: [RESOLVED] HTML Editor Problem

    Hey,

    You might want to think about posting the final code that you used. That way, if someone else is looking for the same thing they will be able to learn.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width