Blog Home  Home Feed your aggregator (RSS 2.0)  
kevin Mocha - Wednesday, November 28, 2007
Bookmarks collected from web.
 
 Wednesday, November 28, 2007

http://forums.asp.net/t/1127834.aspx

 

you can use the following javascript function to set the active tab: 

function SetActiveTab(tabControl, tabNumber)
{
  var ctrl = $find(tabControl);
  ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);
}

tabControl: ID from the TabContainer Controls
tabNumber: Number of the new Tab (starting at 0)

 

Or

 

$find('<%=TabContainer1.ClientID%>').get_activeTabIndex();

and

$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(2);

Wednesday, November 28, 2007 3:54:46 AM UTC  #    Comments [0]    |  |  |   |  Trackback
 Monday, November 19, 2007
 Monday, November 12, 2007

http://blenitz.blogspot.com/2007/09/hidden-columns-with-values-aspgridview.html

(If you don't want to show empty headtitle, put the hidden filed in with other field in one grid colomn)

If you set Column Visible property to false, this column won't rendered. But if you want these values available, What will you do?
My trick was, set HeaderText to empty, convert the BoundField in TemplateField, and use a HiddenField control. The effect the column won't be visible. Also you can use the controls array to access to value property.

<Columns><asp:BoundField DataField="CompanyCode"
HeaderText="Company" SortExpression="CompanyCode" />
...
<Columns>
<asp:TemplateField><ItemTemplate><asp:HiddenField
id="hf1" Value='<%# Bind("CompanyCode") %>'
runat="server"></asp:HiddenField></ItemTemplate>
...
// accesing the value property
int tmpID =
Convert.ToInt32(((HiddenField)GridView1.SelectedRow.Cells[3].Controls[1]).Value);
Monday, November 12, 2007 9:07:00 PM UTC  #    Comments [0]    |   |  Trackback
 Sunday, November 11, 2007

http://www.netomatix.com/development/GridViewRowSelectedEvent.aspx

How to raise gridview server side event when when row is selected

 

http://www.netomatix.com/development/GridViewRowSelectedStyle.aspx

How to highlight gridview when row is selected

 

http://www.netomatix.com/development/GridViewClientSideAccess.aspx

How to access gridview cell values on client side
Sunday, November 11, 2007 4:02:32 PM UTC  #    Comments [0]    |   |  Trackback
 Thursday, November 08, 2007

Following are some of my observations got from the book:

Chapter 1&2

  • XAML is just a way to use .NET APIs. WPF and XAML can be used independently from each other.
  • XAML specification defines rules that map .NET namespaces, types, properties, and events into XML namespaces, elements, and attributes.
  • Markup extensions are just classes with default constructors.
  • An object element can have three types of children: a value for a content property, collection items, or a value that can be type-converted to its parent.

Chapter 3 Important new Concepts in WPF

Logic Tree

The logical tree concept is straightforward, but why should you care about it? Because just about every aspect of WPF (properties, events, resources, and soon) has behavior tied to the logical tree. For example, property values are sometimes propagated down the tree to child elements automatically, and raised events can travel up or down the tree. Both of these behaviors are discussed later in this chapter.

Visual Tree
A similar concept to the logical tree is the visual tree. A visual tree is basically an expansion of a logical tree, in which nodes are broken down into their core visual components. Rather than leaving each element as a “black box,” a visual tree exposes the visual implementation details. For example, although a ListBox is logically a single control, its default visual representation is composed of more primitive WPF elements: a Border, two ScrollBars, and more.

Dependency Properties

A dependency property depends on multiple providers for determining its value at any
point in time. These providers could be an animation continuously changing its value, a
parent element whose property value trickles down to its children, and so on. Arguably
the biggest feature of a dependency property is its built-in ability to provide change notification.

Change Notification (Property Trigger)   

Property Value Inheritance

Multiple Providers

Attached Properties

Routed Events (routing Strategies:tunneling, bubbling, Direct)

Attached Events

Commands: a more abstract and loosely-coupled version of events.

 

image

Thursday, November 08, 2007 7:22:43 PM UTC  #    Comments [0]    |  Trackback

From: http://www.mikeduncan.com/3-hot-uses-for-httpcontextcurrentitems-they-wont-tell-you-about/

Generally, HttpContext.Current.Items doesn’t get all that much hot blog press, but let me tell you, I’m here to change all that. For those out of the know, System.Web.HttpContext.Current.Items is a sweet key-value pair collection you can use to pass objects around up and through all components that participate in a single HTTP request. What does this mean? This means that in a way similar to sticking something in the Session or cache, you can jam some values into the HttpContext.Current.Items for your request, say in a HttpModule way down low before you’ve even begun to fetch a page, and have those values readable/writable later from your page and all its usercontrols. The Items only persist through this one-night-stand of a single request and then supposedly “lose your number” but that’s ok, because we don’t really need all their drama after that anyway.

1) Preparing objects down low, on the down-low.

As alluded to earlier, one sweet use of HCI (as we call in on the street) is in HttpModules. Let’s say you are doing some url-rewriting for user-friendliness or SEO reasons. While you’re at it, why not do a little preparation for your page? If you have a query param of state abbreviation that comes in commonly, populate an additional full state name display field ahead of time. Clean up your strings with proper casing, do whatever utils you think you can get away with while you have the request in your hand. I have a little object of getters and setters that I populate in the the HttpModule, and stick it in the Current.Items for its way up the stack. Now my pages and usercontrols can pull out my cleaned up custom object from the Context.Items and act accordingly, pass it down the line to methods, whatever. The vibe is maybe a hint at a smidgen of a wee bit Model View Controller-ish, but not really.

2) Making params and pages more unit-testable.

With something like #1 in place, you can pull objects of params and prepared goodness out of the request and process them in your code behind, presenter, usercontrol, whatever strikes your pattern fancy. If this bundle of params is a in a nice little object that implements an interface, this makes unit testing logic that under normal circumstances relies upon getting info from the System.Web namespace (querystring params mostly) nice and easily decoupled. Pros of this are that your view calling your presenter can stay super lean and mean without having to populate a bunch info from query strings which will end up going through standard transformations you could have handled earlier on. A con is that the population of these params might be a bit mysterious to other devs who don’t see the HttpModule in action, sort of a like a table that gets populated from somewhere or other, but you don’t know what trigger where. I hate that.

3) Populating usercontrols without the hassle.

If you know you have values in your hand at page on_load or earlier, it’s pretty damn convenient to stick them in the HttpContext.Current.Items and then just read them out from whatever usercontrols may or may not be dynamically included on the page. No finding child controls from the page, no finding parent info from the controls. No casting, scoping or otherwise thinking about precisely what order what will fire. If you have the data at page_load, your controls can get it. Don’t call me, and I won’t call you either. Ta-dow (does anyone say that anymore?).

So there you have it, HttpContext.Current.Items, arcane enough to give you guru-cred to the mid-range noobs, simple enough that it can be leveraged for good and / or evil. Awesome.

Thursday, November 08, 2007 7:19:38 PM UTC  #    Comments [0]    |  Trackback
 Tuesday, November 06, 2007
Show date in english:
ToString("MM/dd", new System.Globalization.CultureInfo("en-us"))

//
// Any source code blocks look like this
//

DateTime dt = DateTime.Now;
String strDate="";
strDate = dt.ToString("MM/dd/yyyy"); // 07/21/2007
strDate = dt.ToString("dddd, dd MMMM yyyy"); //Saturday, 21 July 2007
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm"); // Saturday, 21 July 2007 14:58
strDate = dt.ToString("dddd, dd MMMM yyyy hh:mm tt"); // Saturday, 21 July 2007 03:00 PM
strDate = dt.ToString("dddd, dd MMMM yyyy H:mm"); // Saturday, 21 July 2007 5:01
strDate = dt.ToString("dddd, dd MMMM yyyy h:mm tt"); // Saturday, 21 July 2007 3:03 PM
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:04:10
strDate = dt.ToString("MM/dd/yyyy HH:mm"); // 07/21/2007 15:05
strDate = dt.ToString("MM/dd/yyyy hh:mm tt"); // 07/21/2007 03:06 PM
strDate = dt.ToString("MM/dd/yyyy H:mm"); // 07/21/2007 15:07
strDate = dt.ToString("MM/dd/yyyy h:mm tt"); // 07/21/2007 3:07 PM
strDate = dt.ToString("MM/dd/yyyy HH:mm:ss"); // 07/21/2007 15:09:29
strDate = dt.ToString("MMMM dd"); // July 21
strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"); // 2007-07-21T15:11:19.1250000+05:30
strDate = dt.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"); // Sat, 21 Jul 2007 15:12:16 GMT
strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"); // 2007-07-21T15:12:57
strDate = dt.ToString("HH:mm"); // 15:14
strDate = dt.ToString("hh:mm tt"); // 03:14 PM
strDate = dt.ToString("H:mm"); // 5:15
strDate = dt.ToString("h:mm tt"); // 3:16 PM
strDate = dt.ToString("HH:mm:ss"); // 15:16:29
strDate = dt.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'Z'"); // 2007-07-21 15:17:20Z
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:17:58
strDate = dt.ToString("yyyy MMMM"); // 2007 July
Tuesday, November 06, 2007 10:10:34 PM UTC  #    Comments [0]    |  Trackback

<asp:GridView ID="GridViewYardSales" runat="server" CssClass="yui-datatable-theme"
                            AutoGenerateColumns="false" DataSourceID="YardSaleDataSource" AllowSorting="true"
                            OnRowCommand="GridViewYardSales_RowCommand" OnRowCreated="GridViewYardSales_RowCreated"
                            DataKeyNames="ItemId">
                            <RowStyle CssClass="data-row" />
                            <AlternatingRowStyle CssClass="alt-data-row" />
                            <Columns>
                                <asp:BoundField DataField="ItemId" HeaderText="ItemId" ReadOnly="True" SortExpression="ItemId"
                                    Visible="false"></asp:BoundField>
                                <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButtonViewOnMap" runat="server" OnClientClick=<%# String.Format("javascript:ViewOnMapById('{0}');", Eval("ItemId")) %>>
                                Map</asp:LinkButton><br />
                                        <asp:LinkButton ID="LinkButtonItinerary" runat="server" CommandName="Command_Itinerary"
                                            CommandArgument='<%# Eval("ItemId") %>'>Itinerary </asp:LinkButton><br />
                                        <asp:LinkButton ID="LinkButtonViewDetail" runat="server" CommandName="Command_ViewItemDetail"
                                            CommandArgument='<%# Eval("ItemId") %>'>Detail
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Title">
                                    <ItemTemplate>
                                        <%# Eval("Title") %><br />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Date">
                                    <ItemTemplate>
                                        <%# Eval("Time") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>

 

protected void GridViewYardSales_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Retrieve LinkButton control
                int m_RowIndex = e.Row.RowIndex;
                string id = GridViewYardSales.DataKeys[m_RowIndex].Value.ToString();
                LinkButton lb = (LinkButton)e.Row.FindControl("LinkButtonItinerary");

                if (IsItemAlreadyInItinerary(id))
                {
                    lb.Text = "Remove";
                }
                else
                {
                    lb.Text = "Add";
                }
            }
        }

        protected void GridViewYardSales_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Command_Itinerary")
            {
                string id = e.CommandArgument.ToString();

                GridViewRow selectedRow = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
                LinkButton lb = (LinkButton)selectedRow.FindControl("LinkButtonItinerary");

                if (!IsItemAlreadyInItinerary(id))
                {
                    AddItemToItinerary(id);
                    lb.Text = "Remove";
                }
                else
                {
                    RemoveItemFromItinerary(id);
                    lb.Text = "Add";
                }
            }
            else if (e.CommandName == "Command_ViewItemDetail")
            {
                string id = e.CommandArgument.ToString();
                Response.Redirect("ViewSale.aspx?id=" + id);
            }
        }

Tuesday, November 06, 2007 9:42:39 PM UTC  #    Comments [0]    |   |  Trackback

<asp:GridView ID="GridViewYardSales" runat="server" CssClass="yui-datatable-theme"
                            AutoGenerateColumns="false" DataSourceID="YardSaleDataSource" AllowSorting="true"
                            OnRowCommand="GridViewYardSales_RowCommand" OnRowCreated="GridViewYardSales_RowCreated"
                            DataKeyNames="ItemId">
                            <RowStyle CssClass="data-row" />
                            <AlternatingRowStyle CssClass="alt-data-row" />
                            <Columns>
                                <asp:BoundField DataField="ItemId" HeaderText="ItemId" ReadOnly="True" SortExpression="ItemId"
                                    Visible="false"></asp:BoundField>
                                <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButtonViewOnMap" runat="server" OnClientClick=<%# String.Format("javascript:ViewOnMapById('{0}');", Eval("ItemId")) %>>
                                Map</asp:LinkButton><br />
                                        <asp:LinkButton ID="LinkButtonItinerary" runat="server" CommandName="Command_Itinerary"
                                            CommandArgument='<%# Eval("ItemId") %>'>Itinerary </asp:LinkButton><br />
                                        <asp:LinkButton ID="LinkButtonViewDetail" runat="server" CommandName="Command_ViewItemDetail"
                                            CommandArgument='<%# Eval("ItemId") %>'>Detail
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Title">
                                    <ItemTemplate>
                                        <%# Eval("Title") %><br />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Date">
                                    <ItemTemplate>
                                        <%# Eval("Time") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>

Tuesday, November 06, 2007 9:37:14 PM UTC  #    Comments [0]    |   |  Trackback
Tuesday, November 06, 2007 4:38:17 AM UTC  #    Comments [0]    |   |  Trackback
 Monday, November 05, 2007
Monday, November 05, 2007 9:48:15 PM UTC  #    Comments [0]    |   |  Trackback
 Sunday, November 04, 2007

<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
 <ItemTemplate>
          <%# Convert.ToInt32(DataBinder.Eval(Container, "DataItemIndex")) + 1 %>.
   </ItemTemplate>
 </asp:TemplateField>

Sunday, November 04, 2007 9:19:02 PM UTC  #    Comments [0]    |   |  Trackback
Copyright © 2009 Kevin Mocha. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: