order of event firing problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default order of event firing problem

    Hi all,

    Would really appreciate some help on this one!

    Am trying to make a multilingual site with a button to toggle between
    English and Welsh.

    Have an imagebutton with an onclick event to handle the toggle:

    private void changeLanguage(object sender,
    System.Web.UI.ImageClickEventArgs e)
    {
    if(Session["Language"].ToString()=="English")
    Session["Language"] = "Welsh";
    else
    Session["Language"] = "English";
    }

    The aspx page contains a load of things like this:
    <td><%= ex_lang.getText("5")%></td>

    Which draws in the relevant text from an xml file, picking the correct
    language node according to the Session["Language"]

    The (very weird) problem is that if I hit the button once, nothing
    happens. If I hit it a second time - and every subsequent time - it
    behaves perfectly, translating the text as the page loads.
    I know that Page_Load is called before the click event, and I guess
    that's why this is happening, but how can I prevent this delay?
    I hope I've explained this well enough, if anyone has any suggestions
    I'd really love to hear them.
    Many Thanks
    Steven Shingler
    steven shingler Guest

  2. Similar Questions and Discussions

    1. Click Event Not Firing
      In Framework 1.1 (VS 2003, C#) I've written a server control that contains a button. If I place the control on a page surface, it renders fine and...
    2. event firing problem
      Hi IN my asp.net application (C#.net) i've grid control whith pagerstyle mode=numericpages. in codebehind page i've events for...
    3. 'itemcommand' event not firing
      Hi All, I've been on this problem for many hours now and checked many posts and forums but can still not find an answer. I hope someone can help....
    4. server event not firing
      I have a form with a single field and a submit button with a server event. If I click the submit button, the event runs and everything is fine, if...
    5. OnItemDataBound event not firing
      I am creating a Templated Data-Bound control. When the DataBind() method is called I would like the OnItemDataBound to fire. I can tell something...
  3. #2

    Default Re: order of event firing problem

    I would recommend you not do things like:
    <td><%= ex_lang.getText("5")%></td>

    Instead, use server side controls, and have a function which populates them
    with the correct data.

    In general, I recommend you stay away from server side scripts like that,
    and keep all your code in the codebehind.

    "steven shingler" <steven.shingler@virgin.net> wrote in message
    news:95acc33d.0308010733.35b10d50@posting.google.c om...
    > Hi all,
    >
    > Would really appreciate some help on this one!
    >
    > Am trying to make a multilingual site with a button to toggle between
    > English and Welsh.
    >
    > Have an imagebutton with an onclick event to handle the toggle:
    >
    > private void changeLanguage(object sender,
    > System.Web.UI.ImageClickEventArgs e)
    > {
    > if(Session["Language"].ToString()=="English")
    > Session["Language"] = "Welsh";
    > else
    > Session["Language"] = "English";
    > }
    >
    > The aspx page contains a load of things like this:
    > <td><%= ex_lang.getText("5")%></td>
    >
    > Which draws in the relevant text from an xml file, picking the correct
    > language node according to the Session["Language"]
    >
    > The (very weird) problem is that if I hit the button once, nothing
    > happens. If I hit it a second time - and every subsequent time - it
    > behaves perfectly, translating the text as the page loads.
    > I know that Page_Load is called before the click event, and I guess
    > that's why this is happening, but how can I prevent this delay?
    > I hope I've explained this well enough, if anyone has any suggestions
    > I'd really love to hear them.
    > Many Thanks
    > Steven Shingler

    Marina Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139