Showing posts with label source. Show all posts
Showing posts with label source. Show all posts

Monday, March 26, 2012

ajax toolkit tags

hi, i was just wondering because as i've seen in the examples in this forum, when adding an ajax toolkit, in the source code, you can see <ajaxToolkit:SomeToolkit> if i am not mistaken. but when i try to drag a toolkit to the page, or add a toolkit, the tag is different, like <cc1:SomeToolkit>. this puts me to confusion and i am worried that if i upload this to my host, it will not be recognized by the host and i will be obliged to change it manually. what if i have 50 pages that uses 5-8 ajax toolkits? its really a hard work. but this is just an example. maybe you guys can shed light on this. thank you.

Refer to the following link to understand where the tagprefix comes from and their significance

http://www.microsoft.com/mspress/books/sampchap/5728d.aspx#124

As to your worry about different tagprefixes causing problem, it is unfounded.

The declaration at the top of your aspx page e.g.

<%@. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

and the control tagprefix need to match.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

Other than this all your pages could have different tagprefixes.

Saturday, March 24, 2012

AJAX Timer bug when it updates a panel containing a single Text Box with the characters "&

The Ajax timer seems to have a problem updating a panel what contains a text box that has the characters "<br>\n". Attached is the source code for a very simple page a single multi-line text box where the timer code-behind just assigns the textbox the string "<br>\n". When run, the second update will cause an 500 error from the server.

This error does not happen when the text is something else, say "Hello World".

I assume that the problem is that the sequence "<br>\n" in the text box causes the timer Java Script to break somehow. Anyone knows oh to solve this problem? I am using Ajax 1.0 and the Visual Studio Development Server.

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox> <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"> </asp:Timer> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

The code behind for the time update is:

protected void Timer1_Tick(object sender, EventArgs e) { TextBox1.Text ="<br>\n;"; }

Ivan.

I am sorry, the code for the post got mangled but the editor. The code behind for the time update should be:

public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { }protected void Timer1_Tick(object sender, EventArgs e) { TextBox1.Text = "<br>\n"; }}

Apparently, the string <br> is detected as a potentially harmfull string. One solution is to HTML encode the string. However, I do need to display the string <br> in the text box, not <br>. The user must be able to edit the HTML code that we will use.

Ivan.


Apparently, the string <br> is detected as a potentially harmfull string. One solution is to HTML encode the string. However, I do need to display the string <br> in the text box, not <br>. The user must be able to edit the HTML code that we will use.

Ivan.