The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ComfortASP.NET - selective update & client text change event

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Zeiß

Posts: 44
Nickname: danielz
Registered: Jan, 2006

Daniel Zeiß is author of ComfortASP.NET
ComfortASP.NET - selective update & client text change event Posted: Jan 10, 2006 3:51 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Daniel Zeiß.
Original Post: ComfortASP.NET - selective update & client text change event
Feed Title: Daniel's Blog
Feed URL: /error.aspx?aspxerrorpath=/danielz/Rss.aspx
Feed Description: ComfortASP.NET - AJAX for all
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Daniel Zeiß
Latest Posts From Daniel's Blog

Advertisement

Maybe you are interested in some upcoming features of ComfortASP.NET.

Still going for the goal of pure server side programming, the next version of ComfortASP.NET comes with new Controls that provide some still missing features.

The first Control is called "PanelUpdater" and is used for a so called selective update. You can drop the PanelUpdater into a Panel and ComfortASP.NET will update only this certain Panel - if triggered to do so. This makes it possible to update only parts of the Page and keep UI free of updates you do not need or want.

The second Control is called "ClientEventTextChange" and is used to transport a Text Change event from client to server. Provided with the ID of the TextBox of which you want to get the events on the server it monitors text changes and fires a server side event in a case of any changes.

I implemented this new Example Page to demonstrate the new features.
The demo shows a Google search with Suggest features.

Below you can see the designer window of the Visual Studio Project:

Here is the Source Code - as you can see it's all pure Server Side code:
(ComfortASP.NET is integrated via HttpHandler)

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using ComfortASP;
using testComfortASP.Google;

namespace testComfortASP
{
 public class SelectiveUpdate : Page
 {
  protected ComfortASP_ClientEventTextChange ComfortASP_ClientEventTextChange1;
  protected Label Label1;
  protected ComfortASP_PanelUpdater ComfortASP_PanelUpdater1;
  protected ComfortASP_Manager ComfortASP_Manager1;
  protected Label LabelSearch;
  protected TextBox TextBoxSearchPhrase;
  protected System.Web.UI.WebControls.Panel PanelGoogleResult;
  protected System.Web.UI.WebControls.Panel Panel1;
  protected System.Web.UI.WebControls.LinkButton LinkButtonClearResults;
  protected System.Web.UI.WebControls.Button ButtonUpdate;
  protected System.Web.UI.WebControls.Panel Panel2;
  protected System.Web.UI.WebControls.Panel Panel3;
  protected Label LabelGoogleResults;
 
  override protected void OnInit(EventArgs e)
  {
   InitializeComponent();
   base.OnInit(e);
  }
  
  private void InitializeComponent()
  {   
   this.LinkButtonClearResults.Click += new System.EventHandler(this.LinkButtonClearResults_Click);
   this.ButtonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);

   // Event Handler for new ComfortASP_ClientEventTextChange Control
   this.ComfortASP_ClientEventTextChange1.TextChanged +=
    new ComfortASP.ComfortASP_ClientEventTextChange.TextChangedHandler(
     this.ComfortASP_ClientEventTextChange1_TextChanged);
  }

  private void ComfortASP_ClientEventTextChange1_TextChanged(object sender, EventArgs e)
  {
   DoGoogleSearch();
  }

  private void ButtonUpdate_Click(object sender, System.EventArgs e)
  {
   DoGoogleSearch();
  }

  private void LinkButtonClearResults_Click(object sender, System.EventArgs e )
  {
   TextBoxSearchPhrase.Text = "";
   LabelGoogleResults.Text = "";
  }

  private void DoGoogleSearch()
  {
   string l_SearchPhrase = TextBoxSearchPhrase.Text;

   // Do search with at least 3 characters
   if( l_SearchPhrase.Length >= 3 )
   {
    try
    {
     LabelSearch.Text = ""+l_SearchPhrase+"";

     GoogleSearchService l_GoogleSearchService = new GoogleSearchService();

     GoogleSearchResult l_Result = l_GoogleSearchService.doGoogleSearch(
      "{my google key}",
      l_SearchPhrase, 0, 5, true, "", false, "", "", "");

     string l_Return = string.Empty;

     if( l_Result.resultElements.Length > 0 )
     {
      for (int i = 0; i < l_Result.resultElements.Length; i++)
      {
       l_Return += "<a href='" + l_Result.resultElements[i].URL+ "'>" + l_Result.resultElements[i].title + "</a><br>";
      }
      LabelGoogleResults.Text = l_Return;
      return;
     }
    } catch( Exception ) { }

    LabelGoogleResults.Text = "No Results found or Google search is not possible at the moment, please try again later!";
   }
  }
 }
}

Read: ComfortASP.NET - selective update & client text change event

Topic: Elimination of the file system Previous Topic   Next Topic Topic: SQL Server 2005 AdventureWorks install

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use