Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

Winston Pang Winston Pang
  • object pass by ​value/refer​ence

    I always thought that the terminology was weird, but when people say pass by reference, they always refer it to passing the pointer address/value to the parameters, but from what i've learnt, passing by reference actually means passing a reference of the actual variable address, not the underlying variable object's memory address.


  • How can you handle ALL ASP.NET web controls inside Add​ParsedSub​Object?

    Hey guys,

    i wrote a little custom web control so i can reuse it in my project, basically it has a bunch of div's and labels etc, and then normally within the main div, it should be capable of storing any normal HTML makrup of control, so i was researching and discovered i need to set the ParseChildren attribute to false and override AddParsedSubObject and CreateChildControls, however, for the AddParseSubObject method, i have to go check specifically the type of controls, otherwise they wont render correctly, my question is, how do u handle all the web controls, ill show u some code:


    protected override void AddParsedSubObject(object obj)

    {

    if (obj is LiteralControl)

    {

    this.ViewState["InnerContents"] = ((LiteralControl)obj).Text;

    }

    else if (obj is Repeater)

    {

    mRepeaters.Add((Repeater)obj);

    }

    else if (obj is DataList)

    {

    mDataLists.Add((DataList)obj);

    }

    else if (obj is WebControl)

    {

    mWebControls.Add((WebControl)obj);

    }

    else

    {

    base.AddParsedSubObject(obj);

    }

    }

    protected override void CreateChildControls()

    {

    if (mRepeaters.Count > 0)

    {

    foreach (Repeater repeater in mRepeaters)

    {

    PaneContents.Controls.Add(repeater);

    }

    }

    if (mDataLists.Count > 0)

    {

    foreach (DataList dataList in mDataLists)

    {

    PaneContents.Controls.Add(dataList);

    }

    }

    if (mWebControls.Count > 0)

    {

    foreach (WebControl webControl in mWebControls)

    {

    PaneContents.Controls.Add(webControl);

    }

    }

    }


    As you can see it seems a little cumbersome, adding a type everytime i want to support a control, PaneContents is the div which i want to add the control to.

    I would of thought just checking WebControl and LiteralControl should suffice, but it doesn't.


    My main objective is to achieve:


    <cc:MyControl runat="server" ID="test">

    //markup or Webcontrol here...

    </cc:MyControl>



    Thanks guys

  • How do i get a channel 9  guy?

    I have sent the postcards in!!

    And now i wait for one... which will take months

  • How do i get a channel 9  guy?

    jeffsand wrote:
    The best way is to send us a postcard.

    Channel 9 Team
    One Microsoft Way
    Redmond, WA
    98052

    -Jeff


    Hooray!

    What do i need to say in the postcard?

  • How do i get a channel 9  guy?

    Hey everyone,

    How do i go about getting a channel 9 guy?

    I really want one!


    Thanks!


    Winston

  • How would you validate fields when u want a tailored message for each?

    I want to see how people would approach this in another way.

    Say on a WebForm/WinForm, you have about 10 fields, and you want a different error message for each of them even though all you're testing is that it's filled in, for example "Please fill in your name", "Please fill in your address", etc...

    Normally you'd do a bunch of if's, but it gets kind of messy and your brain tells you that there must be another way of doing this.

    How would some go about handling this?

  • ASP.NET 2.0 Databinding help with an ​implementat​ion

    Thanks i'll look into that.

    What i don't understand is, Using the ObjectDataSource, and if it's a Select method that i create, what type of object is the ObjectDataSource expecting, i'm assuming it should be a List, so that when Binding occurs, it traverses the lists and instantiates a new ItemTemplate for each record in the List, am i on the right track?

    Furthermore if i have custom object types inside the list, does that mean when i do Eval calls, i specify the Property name as the string inside the Eval arguments?

    Furthermore i think the logic behind doing all the mutliple calls will still be complicated.

    As firstly, i'd be selecting all the Posts from the table. So i'll end up with a set of Post records, i'd then have to traverse this set of records and get the Post ID one by one and apply each ID into a select statement to select all the Tags that associated with that Post ID, it might be really inefficient, i'm not sure how i would also mangle the results of the Post record with a list of tags.

    I must be doing something wrong here.

    Any other pointers from anyone else?


    Thank you once again.

  • ASP.NET 2.0 Databinding help with an ​implementat​ion

    So i'm making my own Blog, and it's going to be simple the general layout is:


    DATE - POST TITLE
    - - - - - - - - - - - - - - - - -
    POST CONTENTS
    - - - - - - - - - - - - - - - - -
    TAGS | COMMENT LINK(NUMBER OF COMMENTS)


    So i've used a GridView, and supplied an SqlDataSource all works well, but now i'm trying to incorporate the TAGS feature, but it's kind of hard to do it all in the one single query, i don't think it's even possible.


    My current schema goes something like this


    Post - PostID_PK, Post title, etc
    Comment - CommentID_PK, CommentContents, PostID_FK
    Tag - TagID_PK, TagName
    Tag_Post - Tag_Post_ID_PK, TagID_FK, PostID_FK

    So that's the general layout, for my SqlDataSource i've got a query that will fetch all Posts, and also fetch the number of comments for each post, just a count. Works all well. But now i need to fetch all the Post_Tag records for EACH post, the results will be strange and i'm not sure how it'll work out in DataBinding.

    My next step is to make my own custom data source objects, but i'm not exactly sure how i should model my custom data source objects for me to make my <%# Eval("FieldName") %> calls work still inside my aspx page.

    Thank you in advance.


    Winston

  • Bug inside Web App project templates for Visual Studio 2005?

    Haha alright i feel like an idiot, but they are two different templates

    anyways for anyone who's interested:

    http://msdn2.microsoft.com/en-us/library/aa730880(VS.80).aspx">http://msdn2.microsoft.com/en-us/library/aa730880(VS.80).aspx

  • Bug inside Web App project templates for Visual Studio 2005?

    Well it looks like i've bumped into a bug.

    I know they brought back the create a Web Solution inside the New Project dialog throuhg SP1, but i'm getting the vibe, they just re-enabled it and didn't update the template files accordingly, because if you create it through the New Project dialog, the template generates the Page directives using CodeBehind attribute, which is depericated, while if you make it inside the Web Solution dialog, it generates the correct Attributes using CodeFile attribute.

    Has anyone else experienced the same issue?