Showing posts with label sense. Show all posts
Showing posts with label sense. Show all posts

Monday, March 26, 2012

Design question - UpdatePanel wrapping a GridView

As a general UI design question, I was wondering if it even makes sense (gives any improvement in the user experience, that is) to wrap a GridView in an UpdatePanel, considering that the page's sole purpose is to search for X and the grid displays the search results. There is not much that the user can do with in the page, basically search, view the results, sort them and go to next/previous page of search results.

Is it really worth it? What would be the pros/cons?

Well, I tend to avoid update panels in any case, but assuming you prefer that as your ajax delivery mechanism, I'd say that it still makes sense. Very few pages are completely devoid of anything but a data view; most have (at least) navigation to other pages and some form of branding. Most pages have quite a bit more in terms of markup, including images and other style elements. In short, yeah, there's still some payoff. I'd argue, actually, that a page with just one server-side control is actually a better cantidate for an updatepanel, b/c more server controls = bigger viewstate = less value from your update panel b/c of weight on the wire.


i'm all for wrapping the gridview in an updatepanel. I'm currently writing an app that is 100% postback-less and wrapped in update panels, and with my gridviews i am able to filter, sort, and page the results without a flicker. also, if done correctly, the amount of data transferred over the wire will be less than with a full postback, however, you will not save any memory space on the server, you may even use a little more but not a big deal.


Try the Asp.net Ajax Grid.http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Wednesday, March 21, 2012

Dec Preview CTP, xml-script and simple data binding

Ok my problem is not that my code doesn't work, it does, but it makes no logical sense and I was hoping someone could explain it to me.

The problem is that when data binding programatically, the steps are: create controls (say a textbox and a label), initialize them (sigh), create the binding object, set the properties of the binding, including specifying the label as "target". Here is the complete woking code for this:

// Create and initialize Controls

var textbox =new Sys.Preview.UI.TextBox($get("TextBox1"));
var label =new Sys.Preview.UI.Label($get("Label1"));
textbox.initialize();
label.initialize();

// Create binding

var binding =new Sys.Preview.Binding();
// Set properties and initialize
binding.set_dataContext(textbox);
binding.set_target(label);
binding.set_dataPath("text");
binding.set_property("text");

// Using a standard Transform

binding.add_transform(Sys.Preview.BindingBase.Transformers.ToString);
binding.set_transformerArgument("Text entered: {0}");
binding.initialize();

When you want to do the same thing in xml-script, the rules seem to change. You no longer set the "target" of the binding, but ad the binding to the "bindings" of the label itself. Here is the working code for that:

<

div>
<inputtype="text"id="TextBox1"/><br/>
<labelid="label1"></label>
</div>

</

form>
<scripttype="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="TextBox1" />
<label id="Label1">
<bindings>
<binding dataContext=
"TextBox1"dataPath="text"property="text"transform="ToString"transformerArgument="Text entered: {0}" />
</bindings>

</label>
</components>
</page>
</script>

According to "Programming Atlas" by Wenz, the way the xml-script is doing it is the way it *used to be done* in code. So to set the label as the target, you would have done this:

label.get_bindings().add(binding);

but now, thelabeldoes not have any methods that would support this, like "get_bindings().add" or "add_binding". The code above just fails "object does not support this property or method".

So why is this? Am I missing something? Ths is making no sense to me.

I should say that new APIs are hard enough to learn, but there is no intellisense, and I'm finding places where the API is inconsistant ("get_events" instead of "getEvents" - why the inconsistant camel casing?) And now stuff llike this...?

Also, does anyone know if the dec CTP and the stuff in the "Preview" namespace will be part of RTM1 ? Or will it continue as an unsupported preview. And also,where are the docs for the Preview objects?

Try to take a look at this materials about Futures Dec CTP for reference -http://ajax.asp.net/files/AspNet_AJAX_CTP_to_Beta_Whitepaper.aspx

Hi,

It seems that<binding dataContext="TextBox1"dataPath="text"property="text"transform="ToString"transformerArgument="Text entered: {0}" /> is not working as expected in RC1. ThetransformerArgument doesn't seem to work.

Any idea?

Vlad


Try this (working code snippet)

1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="ControlBindingXmlScript.aspx.cs" Inherits="ControlBindingXmlScript" %>23<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">45<html xmlns="http://www.w3.org/1999/xhtml" >6<head runat="server">7 <title>Untitled Page</title>8<script>9function main()10{11 // Add Client Code here12}13</script>14</head>15<body>16 <form id="form1" runat="server">17 <asp:ScriptManager ID="ScriptManager1" runat="server">18 <Scripts>19 <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" />20 <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewGlitz.js" />21 <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewDragDrop.js" />22 </Scripts>23 </asp:ScriptManager>24 <script>25 Sys.Application.get_events().addHandler("load", main);26 </script>27 <div>28 <input type="text" id="TextBox1" /><br />29 <label id="label1"></label>30 </div>31 </form>32 <script type="text/xml-script">33 <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">34 <components>35 <textBox id="TextBox1" />36 <label id="Label1">37 <bindings>38 <binding dataContext="TextBox1"39 dataPath="text"40 property="text"41 transform="ToString"42 transformerArgument="Text entered: {0}" />43 </bindings>44 </label>45 </components>46 </page>47 </script>48</body>49</html>50
"C#" AutoEventWireup="true" CodeFile="ControlBindingXmlScript.aspx.cs" Inherits="ControlBindingXmlScript" %>

Hi,

You are binding to a label not to a text box. This is still not working (where textBox is an asp:textbox):

<textbox id="textBox">
<bindings>
<binding dataContext="checkBoxBoolean"
dataPath="checked"
property="text"
transform="ToString"
transformArgument="Checkbox is {0}"
direction="InOut" />
</bindings>
</textbox>


Vlad


Hello.

this is working here

<%@. Page Language="C#" AutoEventWireup="true" %>

<!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" runat="server">
<title>Untitled Page</title>
<script>
function main()
{
// Add Client Code here
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" />
</Scripts>
</asp:ScriptManager
<div>
<input type="text" id="TextBox1" /><br />
<input type="text" id="text" />
</div>
</form>
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="TextBox1" />
<textBox id="text">
<bindings>
<binding dataContext="TextBox1"
dataPath="text"
property="text"
transform="ToString"
transformerArgument="Text entered: {0}" />
</bindings>
</textBox>
</components>
</page>
</script>
</body>
</html>

I've noticed that you're using INOUt for the direction of the binding. I think that the ToString transformer only allows you to specify the In direction.