CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 5/24/2005 1:30:18 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 13 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
Gabriel1956
Asp.Net User
What I'm doing wrong?5/24/2005 1:30:18 PM

0/0

I try to create UserControl for switching Language/Country. There are two ImageButtons for two countries. After clicking
on one button, nothing happens. After second click on same button the language changes.
 
Can someone tell me, what I'm doing wrong?
 
Best Regards,
Gabriel
 
 
namespace gg.Controls
{
    using System;
    using System.IO;
    using System.Threading;
    using System.Globalization;
    using System.Web.UI;
    using System.Web.UI.WebControls;
 
    public class Language : UserControl
    {
        public Language()
        {
        }
 
        public string Lang {
            get { return (string)ViewState["LANGUAGE"]; }
            set { ViewState["LANGUAGE"] = value; }
        }
 
        public void SelectLang( object source, CommandEventArgs e )
        {
            Lang = e.CommandName;
            CultureInfo ci = CultureInfo.CreateSpecificCulture( e.CommandName );
            Thread.CurrentThread.CurrentCulture = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
        }
 
        protected override void OnLoad( EventArgs e )
        {
            ImageButton b = new ImageButton();
            b.ID = "lang_de";
            b.CommandName = "de";
            b.Command += new CommandEventHandler( SelectLang );
            if ( Lang == "de" )
                b.ImageUrl = "../images/flag_de1.gif";
            else
                b.ImageUrl = "../images/flag_de0.gif";
            Controls.Add( b );
 
            b = new ImageButton();
            b.ID = "lang_nl";
            b.CommandName = "nl";
            b.Command += new CommandEventHandler( SelectLang );
            if ( Lang == "nl" )
                b.ImageUrl = "../images/flag_nl1.gif";
            else
                b.ImageUrl = "../images/flag_nl0.gif";
            Controls.Add( b );
 
            Controls.Add( new LiteralControl( "<br/>Lang = " + Lang ) );
        }
    }
}

 
blahhumbug
Asp.Net User
Re: What I'm doing wrong?5/24/2005 4:04:10 PM

0/0

Your Lang property doesn't have a default property, so in your OnLoad method, your if/elses will always evaluate to the else clause when it's first loaded. That could be causing the problem.

Hope that helps,
Sam

stevenbey
Asp.Net User
Re: What I'm doing wrong?6/6/2005 5:00:32 PM

0/0

 Gabriel1956 wrote:
I try to create UserControl for switching Language/Country. There are two ImageButtons for two countries. After clicking
on one button, nothing happens. After second click on same button the language changes.
 
Can someone tell me, what I'm doing wrong?
 
Best Regards,
Gabriel
The problem isn't about default values, rather it's about the order in which the methods are processed. Page_Load is executed before Select_Lang, which means that, when the button is clicked the first time, Lang still hasn't been set to a value (the last line of Page_Load), however when the button is clicked, for a second time, the ViewState value has been set and so is displayed.

You need to move the line where you add the LiteralControl to some point later on in the Page's lifecycle. I suggest OnPreRender.

This tutorial explains the order of events in a Page's lifecycle.

Steven Bey

Recursion: see Recursion
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
The Inner Game of Tennis: The Classic Guide to the Mental Side of Peak Performance Authors: W. Timothy Gallwey, Pages: 122, Published: 1997
Women Who Love Too Much: When You Keep Wishing and Hoping He'll Change Authors: Robin Norwood, Pages: 352, Published: 2008
The Way of the Wild Heart: A Map for the Masculine Journey Authors: John Eldredge, Pages: 302, Published: 2006
The Attack Authors: Yasmina Khadra, John Cullen, Pages: 272, Published: 2007
The Cheating Culture: Why More Americans are Doing Wrong to Get Ahead Authors: David Callahan, Pages: 353, Published: 2004
The Abstinence Teacher Authors: Tom Perrotta, Pages: 384, Published: 2008
Gorgias Authors: Plato, Robin Waterfield, Pages: 172, Published: 1998
Waiting to Exhale Authors: Terry McMillan, Pages: 432, Published: 2006
The Distant Land of My Father: A Novel of Shanghai Authors: Bo Caldwell, Pages: 373, Published: 2001
Ender's Game Gift Edition Authors: Orson Scott Card, Pages: 256, Published: 2006

Web:
Don't know what I'm doing wrong - Club CDFreaks - Knowledge is Power I'm backing up some moives and when the Movie goes to the midle end part of it. It skips and start's to brake the image. Like if the DVD media were damaged ...
Anthony Is Right: So that's what I'm doing wrong. Oct 1, 2008 ... So that's what I'm doing wrong. Robert Christgau, giving it up for Girl Talk's conceptual majesty: "Only when I printed out Wikipedia's list ...
Bill Self: "I know I'm doing wrong, but I just can't help myself ... Bill Self: "I know I'm doing wrong, but I just can't help myself". All I can say is, what a douche. No, the NCAA won't come down on him (and it shouldn't). ...
What I'm doing wrong? What I'm doing wrong? (from General Marketing) ... There's no point actually doing any work on the site, since internet marketing is all about luck. ...
I don't know what I'm doing wrong here... - DonationCoder.com I'm sorry, I have no idea what I'm doing wrong so help would be appreciated. Here's what's happening: The Desktop Coral window pops up it ...
WordPress › Support » Tell me what I'm doing wrong! Tell me what I'm doing wrong! (18 posts). GrisePhoto. Member Posted 1 month ago #. Take a look at my blog: http://www.grisephotography.com/ ...
Re: What I'm doing wrong? Ripped tracks won't pla: msg#00008 ... Re: What I'm doing wrong? - Find Help in our multimedia.grip.user Forum.
[modeller_usage] What I'm doing wrong? Re: [modeller_usage] What I'm doing wrong? From: "Peter C. Lai" <. sirmooATcowbert.2y.net. > Prev by Date: [modeller_usage] Nucleic acid-protein complexe ...
Can someone tell me what I'm doing wrong? - Club CDFreaks ... I have tried different media DVD+r/DVD- of Sony, Maxell, Fuji, and Memorex but I still get errors. I have tried different speeds. I've checked firmware, ...
Qt-interest Archive - Don't know what I'm doing wrong.... Subject: Re: Don't know what I'm doing wrong.... From: Juan Rosell ; Date: Wed, 04 May 2005 16:33:08 +0200 ...

Videos:
Havana Cash - Know that I'm doin Wrong Havana Cash - Know that I'm doin Wrong
LS maker test [HELP-Tell me what I'm doing wrong-and tips are ... [PLEASE READ DESCRIPTION!!] ______________________________________ NOTE: I am NOT asking you to critique the animation. This was a fast ...
BKO Holoholo Bird - Doing something wrong I'm doing something wrong since everyone tells me that this fight is easy, so I'm looking for help
I Haunt Wizards - But Comon I'm Useless ( with lyrics ) I Haunt Wizards - But Comon I'm Useless Build it up tear it down, turn round, turn round, oh comon What am I doing wrong? Been so long that ...
I'm still constipated. Am I doing something wrong? Question and Answer with Dr Michael Levitt about Colocap Balance Magnesium Sulphate capsules. This video addresses where to next if the capsules ...
Guitar Hero DS On Tour? Tell me what I'm doin Wrong! You guys can stop commenting on this. I Fixed it. I bought a new one and it works perfectly fine!
Bret Michaels Cheat - GH3 - What am I doing wrong? EDIT: Alright, sorry for the confusion, I just haven't gotten around to telling everyone I got it though. Just wanted to let everyone know that I ...
Megaman- I'm doing it wrong (Fail Vid) I just felt like expressing how bad I am at megaman,although,i love the games.just suck at them. i woulda done commentary but meh voice is really ...
Youtube Poop - I'm Doing It Wrong Utena and Anthy spin on roses while I play unfitting music while I play unfitting music while Mario comes home while every single missile hits the ...




Search This Site:










advice -> i need a tabbed panel

accessing the datagrid with vsz file

handling events in custom controls

server control properties.... by value? or by reference?

support validation

usercontrol problem

control creation in oninit sub

opinion on web1host?

sql server 2005 express edition hosting!!!!!!!!!!!!

host recommendations

user web control not rendering if dynamically created

user control state problem

using javascript and styles in designer

system.web.ui.design.controldesigner ????

composite/template control

problem with datagrid checkbox column checkedchange event

childcontrolscreated and system.nullreferenceexception

events in http pipe not firing correctly, need help from a guru.

multiple rows (datalist details)

applying styles to button

custom control with two data sources

looking for free asp.net hosting for research

slide control needed

components question

hosting/uploading my site?

citrix hosting site?

did they improve the treeview control for 2.0?

browse folder dialog box.

compositedataboundcontrol

postback blues

  Privacy | Contact Us
All Times Are GMT