Search Results

Search found 33613 results on 1345 pages for 'html lists'.

Page 12/1345 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • HTML inside webView

    - by Samuh
    I am posting some data to a server using DefaultHttpClient class and in the response stream I am getting a HTML file. I save the stream as a string and pass it onto another activity which contains a WebView to render this HTML on the screen: response = httpClient.execute(get); InputStream is = response.getEntity().getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(is,"utf-8")); StringBuffer sb = new StringBuffer(); String line; while((line=br.readLine())!=null){ sb.append(line); sb.append("\n"); } is.close(); Intent intent = new Intent(this,Trial.class); intent.putExtra("trial",sb.toString()); startActivity(intent); Log.i("SB",sb.toString()); In Second Activity, the code to load the WebView reads: WebView browser = ((WebView)findViewById(R.id.trial_web)); browser.getSettings().setJavaScriptEnabled(true); browser.loadData(html,"text/html", "utf-8"); When I run this code, the WebView is not able to render the HTML content properly. It actually shows the HTML string in URL encoded format on the screen. Interestingly, If I copy the Loggers output to HTML file and then load this HTML in my WebView(using webview.loadurl(file:///assets/xyz.html)) everything works fine. I suspect some problem with character encoding. What is going wrong here? Please help. Thanks.

    Read the article

  • multiple Perl ` print $cgi->header, <<HTML; .... HTML ` statement gives problem

    - by dexter
    i have something like: #!/usr/bin/perl use strict; use warnings; use CGI::Simple; use DBI; my $cgi = CGI::Simple->new; if ($cgi->param('selid')) { print $cgi->header, <<HTML; <br/>this is SELECT HTML } elsif ($cgi->param('delid')) { print $cgi->header, <<HTML; <b>this is DELETE</b> HTML } elsif ($cgi->param('upid')) { print $cgi->header, <<HTML; <b>this is UPDATE</b> HTML } when i run this i get an error like: Error message: Can't find string terminator " HTML" anywhere before EOF at C:/xampp/htdocs/perl/action.pl line 14. , and when give space between << and HTML; like :print $cgi->header, << HTML; error changes to: Error message: Can't find string terminator " " anywhere before EOF at C:/xampp/htdocs/perl/action.pl line 14. , what would be the reason for this? note: parameters are passed from another page('selid' or 'delid' or 'upid')

    Read the article

  • Newbie Python programmer tangling with Lists.

    - by Sergio Tapia
    Here's what I've got so far: # A. match_ends # Given a list of strings, return the count of the number of # strings where the string length is 2 or more and the first # and last chars of the string are the same. # Note: python does not have a ++ operator, but += works. def match_ends(words): counter = 0 for word in words: if len(word) >= 2 and word[0] == word[-1]: counter += counter return counter # +++your code here+++ return I'm following the Google Python Class, so this isn't homework, but me just learning and improving myself; so please no negative comments about 'not doing my homework'. :P What do you guys think I'm doing wrong here? Here's the result: match_ends X got: 0 expected: 3 X got: 0 expected: 2 X got: 0 expected: 1 I'm really loving Python, so I just know that I'll get better at it. :)

    Read the article

  • embedded php in html to include header (top part of page) into the page

    - by Andy
    Hi there, I'm trying to put the top of my page (which is all html) in a seperate file so I only need to change things once like the menu bar etc. So I googled some and found a solution on this website as well, but it doesn't work and I don't know why. So I have a page like article.html and on the top I have this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <?php include("/pages/header.php"); ?> <!-- rest of the html code --> In the header.php I have the html that should be on the top of each page and it starts with: <?php /** * @author name * website header */ ?> <!-- html code --> So what's wrong with this. When I open the page article.html and right click on it to view the source, I can see the php from above calling the header.php file. Thanks!

    Read the article

  • Replicating multicolumn lists from the Django admin CSS

    - by mfalcon
    Hi, I'm developing a Django project and I've to show a multicolumn list for the different objects of a table. I like the design of the django-admin for showing list-objects so I looked at the code to see how it works. As I am a CSS begginer the code seemed a bit difficult and extensive to comprehend. Is there a simplier way to make what I want or actually the CSS code of the django-admin is the path to follow?

    Read the article

  • Flatten (an irregular) list of lists in Python

    - by telliott99
    Yes, I know this subject has been covered before (here, here, here, here), but AFAIK, all solutions save one choke on a list like this: L = [[[1, 2, 3], [4, 5]], 6] where the desired output is [1, 2, 3, 4, 5, 6] or perhaps even better, an iterator. The only solution I saw that works for an arbitrary nesting is from @Alabaster Codify here: def flatten(x): result = [] for el in x: if hasattr(el, "__iter__") and not isinstance(el, basestring): result.extend(flatten(el)) else: result.append(el) return result flatten(L) So to my question: is this the best model? Did I overlook something? Any problems?

    Read the article

  • what's faster: merging lists or dicts in python?

    - by tipu
    I'm working with an app that is cpu-bound more than memory bound, and I'm trying to merge two things whether they be sets or dicts. Now the thing is i can choose either one, but I'm wondering if merging dicts would be faster since it's all in memory? Or is it always going to be O(n), n being the size of the smaller set. The reason I asked about dicts rather than sets is because I can't convert a set to json, because that results in {key1, key2, key3} and json needs a key/value pair, so I am using a dict so json dumps returns {key1:1, key2:1, key3:1}. Yes this is wasteful, but if it proves to be faster then I'm okay with it.

    Read the article

  • Why doesn't this image sprite menu display properly, and why aren't the links working?

    - by briligg
    The code validates. There should be two more images in the menu on the left, above the visible one of the silo. And each should be a link. http://www.briligg.com/agnosticism.html css is: external style sheet: .menu { position: relative; float: left; margin: 10px; padding: 0; width: 150px; } .menu li { margin: 0; padding: 0; list-style: none; position: absolute; left: 0; top: 260px; } .menu li, .menu a { width: 150px; height: 150px; } internal style sheet: .menu { height: 450px; } .mirror { top: 0; } .mirror { background: url(http://www.briligg.com/images/menu-ag.png) 0 0; } .wormcan { top: 151px; } .wormcan { background: url(http://www.briligg.com/images/menu-ag.png) 0 -151px; } .wormsilo { top: 301px; } .wormsilo { background: url(http://www.briligg.com/images/menu-ag.png) 0 -301px; } html: <ul class="menu"> <li class="mirror"> <a href="whoryou.html"></a> </li> <li class="wormcan"> <a href="aroundyou.html"></a> </li> <li class="wormsilo"> <a href="beyondyou.html"></a> </li> </ul>

    Read the article

  • Custom Items in Lists in C# forms?

    - by chaz
    I'm a bit new to the C#-form app developing and I want know, what's the best way around at making a control that holds a list of horizontal items. In which each of these items are horizontally ruled to it's parent control, contain a thumbnail to the left and a large text block to the right of image and a smaller text block underneath that. So basically this isn't a predefined control I can find in the toolbox. Any ideas?

    Read the article

  • Skip Lists -- ever used them?

    - by Head Geek
    I'm wondering whether anyone here has ever used a skip list. It looks to have roughly the same advantages as a balanced binary tree, but is simpler to implement. If you have, did you write your own, or use a pre-written library (and if so, what was its name)?

    Read the article

  • Predicates and Lists

    - by George
    Hello guys, I have a generic list. Some elements of this list belong to a parent element. I retrieved all these elements from a database and i want to recursively build a tree with them. So, here's what i'm thinking: Here is my predicate: public static bool FindChildren(Int32 parentId,CategoryMapping catMapping) { if (catMapping.parentId == parentId) { return true; } else { return false; } } root = list[0]; root.childrenElements = root.FindAll(FindChildren(root.id,???) I can't figure out how this would work. How can i do this kind of predicate?

    Read the article

  • Common elements comparison between 2 lists.

    - by Daniel
    def common_elements(list1, list2): """ Return a list containing the elements which are in both list1 and list2 >>> common_elements([1,2,3,4,5,6], [3,5,7,9]) [3, 5] >>> common_elements(['this','this','n','that'],['this','not','that','that']) ['this', 'that'] """ for element in list1: if element in list2: return list(element) Got that so far, but can't seem to get it to work! Thanks

    Read the article

  • android nested lists

    - by Raogrimm
    i'm new to programming android and i have found some useful things for my app, but i can't seem to find how to make a list filled with an string array display a new list that is going to be populated with a string array. i would like to have the user choose an item from the top_menu list and from there go to the desired area and have that array appear. this is what i have so far: public class HelloListActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] top_menu = getResources().getStringArray(R.array.top_menu); setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, top_menu)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ??? } }); } all my arrays are working fine, i just don't know how to repopulate a new list with the other array depending on the choice the user made. any help is greatly appreciated

    Read the article

  • HTML: <textarea>-Tag: How to correctly escape HTML and JavaScript content displayed in there?

    - by jens
    Hello, I have a HTML Tag <textarea>$FOO</textarea> and the $FOO Variable will be filled with arbitrary HTML and JavaScript Content, to be displayed and edited within the textarea. What kind of "escaping" do I neet to apply to $FOO? I first tought of escaping it HTML but this didnt work (as I will then get shown not the original HTML Code of $FOO but rather the escaped content. This is of course not what I want: I want to be displayed the unescaped HTML/JS Content of the variable... Is it impossible to display HTML Content within a <textarea> tag and also allow it to be editable as full HTML? thanks jens

    Read the article

  • Trying to parse links in an HTML directory listing using Java regex

    - by DiskCrasher
    Ok I know everyone is going to tell me not to use RegEx for parsing HTML, but I'm programming on Android and don't have ready access to an HTML parser (that I'm aware of). Besides, this is server generated HTML which should be more consistent than user-generated HTML. The regex looks like this: Pattern patternMP3 = Pattern.compile( "<A HREF=\"[^\"]+.+\\.mp3</A>", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); Matcher matcherMP3 = patternMP3.matcher(HTML); while (matcherMP3.find()) { ... } The input HTML is all on one line, which is causing the problem. When the HTML is on separate lines this pattern works. Any suggestions?

    Read the article

  • Download HTML and Images with WGet without first few lines

    - by St. John Johnson
    I'm attempting to use wget with the -p option to download specific documents and the images linked in the HTML. The problem is, the site that is hosting the HTML has some non-html information preceding the HTML. This is causing wget to not interpret the document as HTML and doesn't search for images. Is there a way to have wget strip the first X lines and/or force searching for images? Example URL: http://www.sec.gov/Archives/edgar/data/13239/000119312510070346/ds4.htm First Lines of Content: <DOCUMENT> <TYPE>S-4 <SEQUENCE>1 <FILENAME>ds4.htm <DESCRIPTION>FORM S-4 <TEXT> <HTML><HEAD> <TITLE>Form S-4</TITLE> Last Lines of Content: </BODY></HTML> </TEXT> </DOCUMENT>

    Read the article

  • HTML is not being interpreted after JQuery's .ajax function

    - by Casidiablo
    Hello there... Once I have retrived an HTML string with the $.ajax function I put it into a div... the HTML is a simple message with a <b> tag, but it's not being interpreted by the browser, I mean, the <b> is not making the text bold. Here is what I do: $.ajax({ url: 'index.php?ajax=ejecutar_configuracion&id_gadget=cubrimientos', cache: false, success: function(html){ // html = '<b>hello</b> newton' $('#config_reporte').html(html).dialog({ height: 300, width: 500, modal: true }); } }); As you can see, I'm writing the content of the HTML result into a modal dialog window. Does anybody know why is this happening? This should be something easy to do... but I haven't been able to make it work properly. Thank you so much.

    Read the article

  • Using multiple column layout with HTML 5 and CSS 3

    - by nikolaosk
    This is going to be the fourth post in a series of posts regarding HTML 5. You can find the other posts here , here and here.In this post I will provide a hands-on example with HTML 5 and CSS 3 on how to create a page with multiple columns and proper layout.I will show you how to use CSS 3 to create columns much easier than relying on DIV elements and the float CSS rule.I will also show you how to use browser-specific prefix rules (-ms for Internet Explorer and -moz for Firefox ) for browsers that do not fully support CSS 3.In order to be absolutely clear this is not (and could not be) a detailed tutorial on HTML 5. There are other great resources for that.Navigate to the excellent interactive tutorials of W3School.Another excellent resource is HTML 5 Doctor.Two very nice sites that show you what features and specifications are implemented by various browsers and their versions are http://caniuse.com/ and http://html5test.com/. At this times Chrome seems to support most of HTML 5 specifications.Another excellent way to find out if the browser supports HTML 5 and CSS 3 features is to use the Javascript lightweight library Modernizr.In this hands-on example I will be using Expression Web 4.0.This application is not a free application. You can use any HTML editor you like.You can use Visual Studio 2012 Express edition. You can download it here.I will create a simple page with information about HTML 5, CSS 3 and JQuery. This is the full HTML 5 code. <!DOCTYPE html><html lang="en">  <head>    <title>HTML 5, CSS3 and JQuery</title>    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >    <link rel="stylesheet" type="text/css" href="style.css">       </head>  <body>    <div id="header">      <h1>Learn cutting edge technologies</h1>      <p>HTML 5, JQuery, CSS3</p>    </div>    <div id="main">      <div id="mainnews">        <div>          <h2>HTML 5</h2>        </div>        <div>          <p>            HTML5 is the latest version of HTML and XHTML. The HTML standard defines a single language that can be written in HTML and XML. It attempts to solve issues found in previous iterations of HTML and addresses the needs of Web Applications, an area previously not adequately covered by HTML.          </p>          <div class="quote">            <h4>Do More with Less</h4>            <p>             jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.             </p>            </div>          <p>            The HTML5 test(html5test.com) score is an indication of how well your browser supports the upcoming HTML5 standard and related specifications. Even though the specification isn't finalized yet, all major browser manufacturers are making sure their browser is ready for the future. Find out which parts of HTML5 are already supported by your browser today and compare the results with other browsers.                      The HTML5 test does not try to test all of the new features offered by HTML5, nor does it try to test the functionality of each feature it does detect. Despite these shortcomings we hope that by quantifying the level of support users and web developers will get an idea of how hard the browser manufacturers work on improving their browsers and the web as a development platform.</p>        </div>      </div>              <div id="CSS">        <div>          <h2>CSS 3 Intro</h2>        </div>        <div>          <p>          Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document, including plain XML, SVG and XUL.          </p>        </div>      </div>            <div id="CSSmore">        <div>          <h2>CSS 3 Purpose</h2>        </div>        <div>          <p>            CSS is designed primarily to enable the separation of document content (written in HTML or a similar markup language) from document presentation, including elements such as the layout, colors, and fonts.[1] This separation can improve content accessibility, provide more flexibility and control in the specification of presentation characteristics, enable multiple pages to share formatting, and reduce complexity and repetition in the structural content (such as by allowing for tableless web design).          </p>        </div>      </div>                </div>    <div id="footer">        <p>Feel free to google more about the subject</p>      </div>     </body>  </html>  The markup is very easy to follow. I have used some HTML 5 tags and the relevant HTML 5 doctype.The CSS code (style.css) follows  body{        line-height: 30px;        width: 1024px;        background-color:#eee;      }            p{        font-size:17px;    font-family:"Comic Sans MS"      }      p,h2,h3,h4{        margin: 0 0 20px 0;      }            #main, #header, #footer{        width: 100%;        margin: 0px auto;        display:block;      }            #header{        text-align: center;         border-bottom: 1px solid #000;         margin-bottom: 30px;      }            #footer{        text-align: center;         border-top: 1px solid #000;         margin-bottom: 30px;      }            .quote{        width: 200px;       margin-left: 10px;       padding: 5px;       float: right;       border: 2px solid #000;       background-color:#F9ACAE;      }            .quote :last-child{        margin-bottom: 0;      }            #main{        column-count:2;        column-gap:20px;        column-rule: 1px solid #000;        -moz-column-count: 2;        -webkit-column-count: 2;        -moz-column-gap: 20px;        -webkit-column-gap: 20px;        -moz-column-rule: 1px solid #000;        -webkit-column-rule: 1px solid #000;      }       All the rules in the css code are pretty simple. The layout is achieved with that CSS rule #main{        column-count:2;        column-gap:20px;        column-rule: 1px solid #000;        -moz-column-count: 2;        -webkit-column-count: 2;        -moz-column-gap: 20px;        -webkit-column-gap: 20px;        -moz-column-rule: 1px solid #000;        -webkit-column-rule: 1px solid #000; Do note the column-count,column-gap and column-rule properties. These properties make the two column layout possible.Please have a look at the picture below to see why I used prefixes for Chrome (webkit) and Firefox(moz).It clearly indicates that the CSS 3 column layout are not supported from Firefox and Chrome.   Finally I test my simple HTML 5 page using the latest versions of Firefox,Internet Explorer and Chrome. In my machine I have installed Firefox 15.0.1.Have a look at the picture below to see how the page looks  I have installed Google Chrome 21.0 in my machine.Have a look at the picture below to see how the page looks Have a look at the picture below to see how my page looks in IE 10.  My page looks the same in all browsers. Hope it helps!!!

    Read the article

  • Command line tool to query HTML elements (linux)

    - by ipsec
    I am looking for a (linux) command line tool to parse HTML files and extract some elements, ideally with some XPath-like syntax. I have the following requirements: It must be able to parse arbitrary HTML files (which may contain errors) in a robust manner It must be able to extract text of elements and attributes What I have tried so far: xmlstarlet: would be perfect, but mostly reports errors in files (e.g. entity not defined), even xml fo or htmltidy does not help. xmllint: the best I have found so far, but is not able to extract attribute texts. Something like //a/@href reports <a href="foo">, what I need is just foo. string(//a/@href) works, but queries only the first entry. data is not supported. hxextract: works, but cannot extract attributes. XQilla: would support XPath 2.0 and thus data. It also support xqilla:parse-html, but I have had no luck making this work. Can you recommend me another tool?

    Read the article

  • Configure Thunderbird to never send (or even try to send) HTML emails

    - by Brent.Longborough
    Where can I set it to tell Thunderbird to always send as plain-text emails and never as HTML formatted messages? I hate HTML-based email, and always do everything possible to send my emails as plain text. Thunderbird is always pestering me with questions like "This recipient cannot receive HTML..." or "In order to sign this email, it needs to be converted to plain text..." Is there a way I can simply say to Thunderbird "Look, old chap, it's all plain text, so don't bother me any more, ever, again"?

    Read the article

  • Is there any website editor (html) for Firefox

    - by blade19899
    There are a lot of webdeveloper addons available, for Firefox, like firebug. But is there a html editor addon for Firefox. Which I can edit my website. Viewing the edits real-time (using localhost or via ftp?) and saving the edits(CTRL+S) I am currenlty using firebug and it would save a lot of time if I could save the (local) .html file using a firebug like addon!(or firebug itself?) I Found a firebug addon to save .css files... now just need one to save html, and I am good to go!

    Read the article

  • rewrite all .html extension and remove index in Nginx

    - by Pardoner
    How would I remove all .html extensions as well as any occurrences of index.html from a url string in Nginx http://www.mysite/index.html to http://www.mysite http://www.mysite/articles/index.html to http://www.mysite/articles http://www.mysite/contact.html to http://www.mysite/contact http://www.mysite/foo/bar/index.html to http://www.mysite/foo/bar EDIT: Here is my conf file: server { listen 80; server_name staging.mysite.com; root /var/www/staging.mysite.com; index index.html index.htm; access_log /var/log/nginx/staging.mysite.com.log spiegle; #error_page 404 /404.html; #error_page 500 503 /500.html; rewrite ^(.*/)index\.html$ $1; rewrite ^(/.+)\.html$ $1; rewrite ^(.*/)index\.html$ $scheme://$host$1 permanent; rewrite ^(/.+)\.html$ $scheme://$host$1 permanent; location / { rewrite ^/about-us /about permanent rewrite ^/contact-us /contact permanent; try_files $uri.html $uri/ /index.html; } }

    Read the article

  • Adding the New HTML Editor Extender to a Web Forms Application using NuGet

    - by Stephen Walther
    The July 2011 release of the Ajax Control Toolkit includes a new, lightweight, HTML5 compatible HTML Editor extender. In this blog entry, I explain how you can take advantage of NuGet to quickly add the new HTML Editor control extender to a new or existing ASP.NET Web Forms application. Installing the Latest Version of the Ajax Control Toolkit with NuGet NuGet is a package manager. It enables you to quickly install new software directly from within Visual Studio 2010. You can use NuGet to install additional software when building any type of .NET application including ASP.NET Web Forms and ASP.NET MVC applications. If you have not already installed NuGet then you can install NuGet by navigating to the following address and clicking the giant install button: http://nuget.org/ After you install NuGet, you can add the Ajax Control Toolkit to a new or existing ASP.NET Web Forms application by selecting the Visual Studio menu option Tools, Library Package Manager, Package Manager Console: Selecting this menu option opens the Package Manager Console. You can enter the command Install-Package AjaxControlToolkit in the console to install the Ajax Control Toolkit: After you install the Ajax Control Toolkit with NuGet, your application will include an assembly reference to the AjaxControlToolkit.dll and SanitizerProviders.dll assemblies: Furthermore, your Web.config file will be updated to contain a new tag prefix for the Ajax Control Toolkit controls: <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <pages> <controls> <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /> </controls> </pages> </system.web> </configuration> The configuration file installed by NuGet adds the prefix ajaxToolkit for all of the Ajax Control Toolkit controls. You can type ajaxToolkit: in source view to get auto-complete in Source view. You can, of course, change this prefix to anything you want. Using the HTML Editor Extender After you install the Ajax Control Toolkit, you can use the HTML Editor Extender with the standard ASP.NET TextBox control to enable users to enter rich formatting such as bold, underline, italic, different fonts, and different background and foreground colors. For example, the following page can be used for entering comments. The page contains a standard ASP.NET TextBox, Button, and Label control. When you click the button, any text entered into the TextBox is displayed in the Label control. It is a pretty boring page: Let’s make this page fancier by extending the standard ASP.NET TextBox with the HTML Editor extender control: Notice that the ASP.NET TextBox now has a toolbar which includes buttons for performing various kinds of formatting. For example, you can change the size and font used for the text. You also can change the foreground and background color – and make many other formatting changes. You can customize the toolbar buttons which the HTML Editor extender displays. To learn how to customize the toolbar, see the HTML Editor Extender sample page here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx Here’s the source code for the ASP.NET page: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Add Comments</title> </head> <body> <form id="form1" runat="server"> <div> <ajaxToolkit:ToolkitScriptManager ID="TSM1" runat="server" /> <asp:TextBox ID="txtComments" TextMode="MultiLine" Columns="50" Rows="8" Runat="server" /> <ajaxToolkit:HtmlEditorExtender ID="hee" TargetControlID="txtComments" Runat="server" /> <br /><br /> <asp:Button ID="btnSubmit" Text="Add Comment" Runat="server" onclick="btnSubmit_Click" /> <hr /> <asp:Label ID="lblComment" Runat="server" /> </div> </form> </body> </html> Notice that the page above contains 5 controls. The page contains a standard ASP.NET TextBox, Button, and Label control. However, the page also contains an Ajax Control Toolkit ToolkitScriptManager control and HtmlEditorExtender control. The HTML Editor extender control extends the standard ASP.NET TextBox control. The HTML Editor TargetID attribute points at the TextBox control. Here’s the code-behind for the page above:   using System; namespace WebApplication1 { public partial class Default : System.Web.UI.Page { protected void btnSubmit_Click(object sender, EventArgs e) { lblComment.Text = txtComments.Text; } } }   Preventing XSS/JavaScript Injection Attacks If you use an HTML Editor -- any HTML Editor -- in a public facing web page then you are opening your website up to Cross-Site Scripting (XSS) attacks. An evil hacker could submit HTML using the HTML Editor which contains JavaScript that steals private information such as other user’s passwords. Imagine, for example, that you create a web page which enables your customers to post comments about your website. Furthermore, imagine that you decide to redisplay the comments so every user can see them. In that case, a malicious user could submit JavaScript which displays a dialog asking for a user name and password. When an unsuspecting customer enters their secret password, the script could transfer the password to the hacker’s website. So how do you accept HTML content without opening your website up to JavaScript injection attacks? The Ajax Control Toolkit HTML Editor supports the Anti-XSS library. You can use the Anti-XSS library to sanitize any HTML content. The Anti-XSS library, for example, strips away all JavaScript automatically. You can download the Anti-XSS library from NuGet. Open the Package Manager Console and execute the command Install-Package AntiXSS: Adding the Anti-XSS library to your application adds two assemblies to your application named AntiXssLibrary.dll and HtmlSanitizationLibrary.dll. After you install the Anti-XSS library, you can configure the HTML Editor extender to use the Anti-XSS library your application’s web.config file: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="system.web"> <section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/> </sectionGroup> </configSections> <system.web> <sanitizer defaultProvider="AntiXssSanitizerProvider"> <providers> <add name="AntiXssSanitizerProvider" type="AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider"></add> </providers> </sanitizer> <compilation debug="true" targetFramework="4.0" /> <pages> <controls> <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /> </controls> </pages> </system.web> </configuration> Summary In this blog entry, I described how you can quickly get started using the new HTML Editor extender – included with the July 2011 release of the Ajax Control Toolkit – by installing the Ajax Control Toolkit with NuGet. If you want to learn more about the HTML Editor then please take a look at the Ajax Control Toolkit sample site: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >