Home Search Member List Faq Register Login  
UltimateAjax
TextBox event

Thread Starter: vasilaky   Started: 08-31-2008 3:22 PM   Replies: 6
 Karamasoft Support Forums » General Discussions » UltimateAjax » TextBox event
 Printable Version    « Previous Thread   Next Thread »
  31 Aug 2008, 3:22 PM
vasilaky is not online. Last active: 5/1/2009 10:59:27 AM vasilaky

Top 10 Posts
Joined on 02-12-2008
Posts 41
TextBox event
Using C# with VS2005

I would like to programmatically change from one EditorSource to another in UltimateEditor if a certain substring is detected in a TextBox

The only event that I see for the TexBox is TextChange. So, on every TextChange I call a function that checks if the substring  is detected:

protected void TextBox1_TextChanged(object sender, EventArgs e)

{

if(MailServices.Check(TextBox1.Text)) UltimateEditor1.EditorSource="~/UltimateEditorInclude/EmailEditor.xml";

else {}

}

My question: How do I use UltimateAjax to do this?
What goes into UltimateAjax1_Callback function?


  
  02 Sep 2008, 1:08 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: TextBox event
Yes, you should use the Callback event handler of your UltimateAjax control to set the EditorSource property of your UltimateEditor control. Please refer to our UltimateAjax/UltimateEditor integration sample at http://www.karamasoft.com/Samples.aspx?component=UltimateAjax&sample=AjaxEditor to see how you can achieve this.
  
  03 Sep 2008, 3:33 PM
vasilaky is not online. Last active: 5/1/2009 10:59:27 AM vasilaky

Top 10 Posts
Joined on 02-12-2008
Posts 41
Re: TextBox event
I tried several variations of the referenced code but no luck.
Here is what I tried:
Any hint what I'm doing wrong will help. Thanks

*******************ASPX Code:*********************

<head>

<script language="javascript">

function UpdateEditor() {

DoUltimateCallback('UltimateAjax1');

}

</script>

</head>

<body>

<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" Width="450px"></asp:TextBox><br />

 

 

</body>

*******************CS Code*******************

protected void UltimateAjax1_Callback(object sender, Karamasoft.WebControls.UltimateAjax.CallbackEventArgs e)

{

if(Check(TextBox1.Text)) UltimateEditor1.EditorSource = "~/UltimateEditorInclude/UltimateEditorFull.xml";

}

public bool Check(string emaildomain)

{

return emaildomain.Contains("@karamasoft.com");

}

 

protected void TextBox1_TextChanged(object sender, EventArgs e)

{

TextBox1.Attributes.Add("onchange", "UpdateEditor();");

}



  
  03 Sep 2008, 6:32 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: TextBox event
Can you make sure that UltimateAjax1_Callback event handler fires by placing a break-point in it?

If you are using user-controls or master pages, the client-side of your UltimateAjax control might be different than 'UltimateAjax1'. You can try the following code instead:

DoUltimateCallback('<%=UltimateAjax1.ClientID%>');


  
  04 Sep 2008, 4:42 PM
vasilaky is not online. Last active: 5/1/2009 10:59:27 AM vasilaky

Top 10 Posts
Joined on 02-12-2008
Posts 41
Re: TextBox event

The UltimateAjax1_Callback  does not fire even when I try your example, slightly abridged.
http://www.karamasoft.com/Samples.aspx?component=UltimateAjax&sample=AjaxEditor

Can you spot anything wrong? This is basically your example code.

%@ Register TagPrefix="cc1" Namespace="Karamasoft.WebControls.UltimateAjax" Assembly="UltimateAjax" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Samples_UpdateContent_UpdateSource_Default" %>

<%@ Register Assembly="UltimateAjax" Namespace="Karamasoft.WebControls.UltimateAjax"

TagPrefix="cc1" %>

<%@ Register Assembly="UltimateEditor" Namespace="Karamasoft.WebControls.UltimateEditor"

TagPrefix="kswc" %>

<!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 id="Head1">

<title>Untitled Page</title>

<script type="text/jscript" language="javascript">

function UpdateEditor(param) {

DoUltimateCallback('UltimateAjax1', param);

}

</script>

</head>

<body id="try">

<form id="form1" runat="server">

<table cellpadding="5">

<tr style="FONT-SIZE:8pt; FONT-FAMILY:Verdana">

<td ><b>Theme</b>:</td>

<td >

<asp:DropDownList id="ddlTheme" runat="server" style="FONT-SIZE:8pt; FONT-FAMILY:Verdana">

<asp:ListItem Selected="True">Office2003</asp:ListItem>

<asp:ListItem>VSNET2005</asp:ListItem>

<asp:ListItem>Standard</asp:ListItem>

</asp:DropDownList>

</td>

</tr>

</table>

<cc1:UltimateAjax ID="UltimateAjax1" runat="server" Height="402px" Width="867px">

<kswc:UltimateEditor ID="UltimateEditor1" runat="server" EditorSource="~/UltimateEditorInclude/UltimateEditorBasic.xml">

<UltimateSpell MisspelledWordStyle-Font-Bold="True" MisspelledWordStyle-ForeColor="Red">

<SpellButton ButtonType="Button" CausesValidation="True" ImageAlign="AbsMiddle" ImageUrl=""

Text="Spell Check" />

</UltimateSpell>

</kswc:UltimateEditor>

</cc1:UltimateAjax>

</form>

</body>

</html>

 

 

********************CS Code************

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

 

public partial class Samples_UpdateContent_UpdateSource_Default : System.Web.UI.Page

{

private void InitializeComponent()

{

}

private void Page_Init(object sender, System.EventArgs e)

{

// CODEGEN: This method call is required by the Web Form Designer

// Do not modify it using the code editor.

InitializeComponent();

}

protected void Page_Load(object sender, EventArgs e)

{

ddlTheme.Attributes.Add("onchange", "UpdateEditor('theme');");

}

protected void UltimateAjax1_Callback(object sender, Karamasoft.WebControls.UltimateAjax.CallbackEventArgs e)

{

switch (e.Argument)

{

case "theme":

UltimateEditor1.Theme = ddlTheme.SelectedValue;

break;

}

}

}


  
  04 Sep 2008, 6:53 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: TextBox event
Our sample code goes into the Callback event handler as you can see when you change the value in the Theme dropdown, it sets the theme properly. How did you figure out the sample code does not go into the event handler? Add the following line into the Callback event handler:

protected void UltimateAjax1_Callback(object sender, Karamasoft.WebControls.UltimateAjax.CallbackEventArgs e)
{
   System.Diagnostics.Debugger.Break();
   ...
}

to see whether the debugger goes into that line.


  
  05 Sep 2008, 8:03 PM
vasilaky is not online. Last active: 5/1/2009 10:59:27 AM vasilaky

Top 10 Posts
Joined on 02-12-2008
Posts 41
Re: TextBox event
My oversight I did not have:

private void InitializeComponent()

{

this.UltimateAjax1.Callback += new Karamasoft.WebControls.UltimateAjax.UltimateAjax.CallbackEventHandler(this.UltimateAjax1_Callback);

}

in my code.

It's working now.
Thanks


  
 Page 1 of 1 (7 items)
Karamasoft Support Forums » General Discussions » UltimateAjax » TextBox event

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.