Vimal Saifudin's Blog

AJAX is used for interactive communication with a database. 

 The following example will demonstrate how a web page can fetch information from a database with AJAX: 

function AjaxSearch(applicant_id){   

 var http = new XMLHttpRequest(); 

  var url =‘AjaxSearch.php’; 

  var Keywords=document.getElementById(‘txtKeywords’).value; 

var params = “value=”+Keywords+“&applicant_id=”+applicant_id; 

http.open(“POST”, url, true); 

http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”); 

http.setRequestHeader(“Content-length”, params.length); 

http.setRequestHeader(“Connection”, “close”); 

http.onreadystatechange = function()  

{ 

       if(http.readyState == 4 && http.status == 200) 

  { 

                  DisplaySearch(http.responseText); 

  } 

} 

http.send(params); 

} 

function DisplaySearch(Response) 

{ 

$(“#SearchResults”).slideDown(“3000”); 

$(this).toggleClass(“basicSearchTab”);  

scrollToHere(‘SearchResults’); 

document.getElementById(‘SearchResults’).innerHTML = Response; 

 } 

 

function scrollToHere(location){ 

$(‘html, body’).animate({ 

scrollTop: $(“#”+location).offset().top 

}, 2000); 

AjaxSearch.php 

<?php

if (!get_magic_quotes_gpc()) {

     $value = addslashes($_POST['value']);
   $applicant_id = addslashes($_POST['applicant_id']);

}

include_once    ‘../../init.php';

include_once   ‘../../functions.php’;

echo searchJobs ($value,$applicant_id); 

?>

This accordion can be customized in size through HTML and XML. The images passed to it can have different sizes, because the accordion adjusts accordingly.

On click, a slide opens and shows the information passed through XML. You can customize all colors, and the description text can have CSS applied to it as well. (check the first slide example)

If there’s less text in the description, the text box repositions itself in the image space.

Product Link : http://www.flabell.com/flash/Accordion-Banner-Rotator-276

Product Cost : $14

Hopefully some of you have picked up the recent blog post by Colin Eberhardt, entitled Silverlight MultiBindings, How to attached multiple bindings to a single property.  It provides an excellent basis for multi-binding support in Silverlight until they actually get on with it and become more compatible with WPF and have multi-binding directly built in!

However, when I came to use the multi-binding support, there was a limit with Colin’s original design that you can only have one multi-binding per element, as you can see by this example:

 

<TextBlock x:Name=”Block” Foreground=”White” FontSize=”13″
          
Margin=”5,0,0,0″>
    <
local:BindingUtil.MultiBinding>
        <
local:MultiBinding TargetProperty=”Text” Converter=”{StaticResource TitleConverter}”>
            <
Binding Path=”Surname”/>                           
            <
Binding Path=”Forename”/>
        </
local:MultiBinding>
    </
local:BindingUtil.MultiBinding>
</
TextBlock>

If you also wanted to hide the text block if forename or surname were empty, under the original design that you couldn’t do this, because you can only have one target property. So I’ve made some changes which allows you to have multiple multi-bindings per element.  So to make the example I’m describing possible the code would now look like this:

<TextBlock x:Name="Block" Foreground="White" FontSize="13"
           Margin="5,0,0,0">
    <local:BindingUtil.MultiBindings>
        <local:MultiBindings>
            <local:MultiBinding TargetProperty="Text" 
     Converter="{StaticResource TitleConverter}">
                <Binding Path="Surname"/>
                <Binding Path="Forename"/>
            </local:MultiBinding>
            <local:MultiBinding TargetProperty="Visibility" 
 Converter="{StaticResource TitleToVisibiltyConverter}">
                <Binding Path="Surname"/>
                <Binding Path="Forename"/>
            </local:MultiBinding>
        </local:MultiBindings>
    </local:BindingUtil.MultiBindings>
</TextBlock>

 

So, now you can have an unlimited number of multi-bindings 
on the TextBlock!

Unfortunately, this makes a single multi-binding slightly 
more complicated because you need to declare the multi-bindings
object to contain only a single binding. So the original example, 
if you were just having a single binding it would look like this:

 

 

<TextBlock x:Name="Block" Foreground="White" FontSize="13"
           Margin="5,0,0,0">
    <local:BindingUtil.MultiBindings>
        <local:MultiBindings>
            <local:MultiBinding TargetProperty="Text" 
Converter="{StaticResource TitleConverter}">
                <Binding Path="Surname"/>
                <Binding Path="Forename"/>
            </local:MultiBinding>
        </local:MultiBindings>
    </local:BindingUtil.MultiBindings>
</TextBlock>
 

WPF Compatibility

The code here should (in theory) be compatible with WPF if you want 
to single source your xaml code between WPF and Silverlight. 

 

 

 

Categories

Recent Comments

Alvin Alex on Improvements to Silverlight Mu…

Calendar

September 2014
M T W T F S S
« Apr    
1234567
891011121314
15161718192021
22232425262728
2930  

test

Useful Links

Follow

Get every new post delivered to your Inbox.