views:

35

answers:

0

i have used this example ...(with some changes ) and works fine.

http://weblogs.asp.net/johnkatsiotis/archive/2008/07/23/asp-net-ajax-4-0-template-example.aspx

here is code of .aspx page from my example

<div  id="divdata" class="sys-template" style="background-color:Gray" >
    <p>Event Title:<input  id="title"  size="150" type="text" 
            style="background-color:yellow;font-size:25px;width: 637px;"  
            readonly="readonly" value="{{title}}" />
        </p>       


    <p>Event Date: <input type="text" id="date" value="{{ date }}" readonly="readonly" 
            style="width: 251px"/></p>
    <p>Keywords : <input type="text" id="keywords" value="{{keywords}}" readonly="readonly" /></p> 
      </div>

<script type="text/javascript">
    Sys.Application.add_init(appInit);
    function appInit() {
        start();
    }
</script>

this "start()" calls a wcf service which returns result which is rendered like:

function callbackEvent(_result)

{

        var result=_result;
     var title = result.Title;
     var data = result.Data;

  var s = result.DateTime.DateTime.slice(6,19);
  var n = parseInt(s);
  var d = new Date(n);
  var date = d.format("dddd, MMMM dd hh:mm tt");


  var keywords = result.Keywords;


  var t = new Sys.Preview.UI.Template.getTemplate($get("divdata"));
  t.createInstance($get("datashow"),
    {
        title: title,
        data: data,
        date: date,

        keywords: keywords
    });

}

<div id="datashow"></div>

Problem

i have externalised the "divdata" into html file (ie cut "divdata" and paste it into another .htm file) where user can edit it now, the service which is called has n number of parameters ex. title, id, data,size,image..etc and a user will be provided with the list of parameters,

this leaves me with ways options pls help to solve

1. the problem is how can i programatically will understand that which parameters are used by user and then use them in code eg.

  var result=_result;
    var title = result.Title;
    var data = result.Data;

    var s = result.DateTime.DateTime.slice(6,19);
    var n = parseInt(s);
    var d = new Date(n);
    var date = d.format("dddd, MMMM dd hh:mm tt");


    var keywords = result.Keywords;


    var t = new Sys.Preview.UI.Template.getTemplate($get("divdata"));
    t.createInstance($get("datashow"),
{
    title: title,
    data: data,
    date: date,

    keywords: keywords
});

2. is there another way to do:

 var t = new Sys.Preview.UI.Template.getTemplate($get("divdata"));
    t.createInstance($get("datashow"),
{
    title: title,
    data: data,
    date: date,

    keywords: keywords
});

where "divdata" is externalize in .htm page