Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > User control refresh

Reply
Thread Tools

User control refresh

 
 
TCORDON
Guest
Posts: n/a
 
      10-25-2005
I have a user control that contains 2 image buttons, when you click one of
them, both must change the image source, the thing is that the first time
you click any one of them the page appears to do a postbak, but the image
source or the image displayed does not change until I click one of the
images a second time, why dows it take 2 clicks for the user to "refresh"?

TIA!


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-25-2005
TCordian,

If the buttons happen to be in a user control that is being added to the
page dynamically then give the control an ID by adding me.ID =
"MyControlIDHere" to the page load of the control.

I can't tell you why this works exactly, but it does. If this isn't a
dynamically added control please show some source code and I'll see if I can
figure out what's wrong.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TCORDON" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a user control that contains 2 image buttons, when you click one of
>them, both must change the image source, the thing is that the first time
>you click any one of them the page appears to do a postbak, but the image
>source or the image displayed does not change until I click one of the
>images a second time, why dows it take 2 clicks for the user to "refresh"?
>
> TIA!
>



 
Reply With Quote
 
 
 
 
TCORDON
Guest
Posts: n/a
 
      10-25-2005
This usercontrol has 1 image button that is supposed to do the work, this
control is used for country selection between 2 countries. It also has an
<IMG> that shows the selected country (The imagebutton shows the other
country option) so when toy click the image button it is supposed to change
the <IMG> to show the newly selected country and at that time change a
cookie value and a session var value to hold the current country ID, this
should also refresh the page that contains the usercontrol to show content
according to the current selected country.

The imagebutton_click event is coded as follows:

Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click

If p_IdPais = 1 Then

p_IdPais = 2

Session("IdPais") = 2

Else

p_IdPais = 1

Session("IdPais") = 1

End If

'Set Cookie

Dim ACookie As New HttpCookie("MyPageCountry")

ACookie.Values("Pais") = p_IdPais

ACookie.Expires = DateTime.MaxValue

Response.Cookies.Set(ACookie)

End Sub


HELP APPRECIATED
THANKS


"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:(E-Mail Removed)...
> TCordian,
>
> If the buttons happen to be in a user control that is being added to the
> page dynamically then give the control an ID by adding me.ID =
> "MyControlIDHere" to the page load of the control.
>
> I can't tell you why this works exactly, but it does. If this isn't a
> dynamically added control please show some source code and I'll see if I
> can figure out what's wrong.
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "TCORDON" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have a user control that contains 2 image buttons, when you click one of
>>them, both must change the image source, the thing is that the first time
>>you click any one of them the page appears to do a postbak, but the image
>>source or the image displayed does not change until I click one of the
>>images a second time, why dows it take 2 clicks for the user to "refresh"?
>>
>> TIA!
>>

>
>



 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-25-2005
TCORDON,

Just going through troubleshooting steps here...

Are you using smart navigation?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TCORDON" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This usercontrol has 1 image button that is supposed to do the work, this
> control is used for country selection between 2 countries. It also has an
> <IMG> that shows the selected country (The imagebutton shows the other
> country option) so when toy click the image button it is supposed to
> change the <IMG> to show the newly selected country and at that time
> change a cookie value and a session var value to hold the current country
> ID, this should also refresh the page that contains the usercontrol to
> show content according to the current selected country.
>
> The imagebutton_click event is coded as follows:
>
> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e As
> System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>
> If p_IdPais = 1 Then
>
> p_IdPais = 2
>
> Session("IdPais") = 2
>
> Else
>
> p_IdPais = 1
>
> Session("IdPais") = 1
>
> End If
>
> 'Set Cookie
>
> Dim ACookie As New HttpCookie("MyPageCountry")
>
> ACookie.Values("Pais") = p_IdPais
>
> ACookie.Expires = DateTime.MaxValue
>
> Response.Cookies.Set(ACookie)
>
> End Sub
>
>
> HELP APPRECIATED
> THANKS
>
>
> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
> message news:(E-Mail Removed)...
>> TCordian,
>>
>> If the buttons happen to be in a user control that is being added to the
>> page dynamically then give the control an ID by adding me.ID =
>> "MyControlIDHere" to the page load of the control.
>>
>> I can't tell you why this works exactly, but it does. If this isn't a
>> dynamically added control please show some source code and I'll see if I
>> can figure out what's wrong.
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "TCORDON" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I have a user control that contains 2 image buttons, when you click one
>>>of them, both must change the image source, the thing is that the first
>>>time you click any one of them the page appears to do a postbak, but the
>>>image source or the image displayed does not change until I click one of
>>>the images a second time, why dows it take 2 clicks for the user to
>>>"refresh"?
>>>
>>> TIA!
>>>

>>
>>

>
>



 
Reply With Quote
 
TCORDON
Guest
Posts: n/a
 
      10-25-2005
No, Im not.


"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:(E-Mail Removed)...
> TCORDON,
>
> Just going through troubleshooting steps here...
>
> Are you using smart navigation?
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "TCORDON" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> This usercontrol has 1 image button that is supposed to do the work, this
>> control is used for country selection between 2 countries. It also has an
>> <IMG> that shows the selected country (The imagebutton shows the other
>> country option) so when toy click the image button it is supposed to
>> change the <IMG> to show the newly selected country and at that time
>> change a cookie value and a session var value to hold the current country
>> ID, this should also refresh the page that contains the usercontrol to
>> show content according to the current selected country.
>>
>> The imagebutton_click event is coded as follows:
>>
>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e As
>> System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>
>> If p_IdPais = 1 Then
>>
>> p_IdPais = 2
>>
>> Session("IdPais") = 2
>>
>> Else
>>
>> p_IdPais = 1
>>
>> Session("IdPais") = 1
>>
>> End If
>>
>> 'Set Cookie
>>
>> Dim ACookie As New HttpCookie("MyPageCountry")
>>
>> ACookie.Values("Pais") = p_IdPais
>>
>> ACookie.Expires = DateTime.MaxValue
>>
>> Response.Cookies.Set(ACookie)
>>
>> End Sub
>>
>>
>> HELP APPRECIATED
>> THANKS
>>
>>
>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>> message news:(E-Mail Removed)...
>>> TCordian,
>>>
>>> If the buttons happen to be in a user control that is being added to the
>>> page dynamically then give the control an ID by adding me.ID =
>>> "MyControlIDHere" to the page load of the control.
>>>
>>> I can't tell you why this works exactly, but it does. If this isn't a
>>> dynamically added control please show some source code and I'll see if I
>>> can figure out what's wrong.
>>>
>>> --
>>> Sincerely,
>>>
>>> S. Justin Gengo, MCP
>>> Web Developer / Programmer
>>>
>>> www.aboutfortunate.com
>>>
>>> "Out of chaos comes order."
>>> Nietzsche
>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I have a user control that contains 2 image buttons, when you click one
>>>>of them, both must change the image source, the thing is that the first
>>>>time you click any one of them the page appears to do a postbak, but the
>>>>image source or the image displayed does not change until I click one of
>>>>the images a second time, why dows it take 2 clicks for the user to
>>>>"refresh"?
>>>>
>>>> TIA!
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-25-2005
Ok,

Then two more questions...

1) How are you setting the image urls?
2) What are the image names?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TCORDON" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> No, Im not.
>
>
> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
> message news:(E-Mail Removed)...
>> TCORDON,
>>
>> Just going through troubleshooting steps here...
>>
>> Are you using smart navigation?
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "TCORDON" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> This usercontrol has 1 image button that is supposed to do the work,
>>> this control is used for country selection between 2 countries. It also
>>> has an <IMG> that shows the selected country (The imagebutton shows the
>>> other country option) so when toy click the image button it is supposed
>>> to change the <IMG> to show the newly selected country and at that time
>>> change a cookie value and a session var value to hold the current
>>> country ID, this should also refresh the page that contains the
>>> usercontrol to show content according to the current selected country.
>>>
>>> The imagebutton_click event is coded as follows:
>>>
>>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e
>>> As System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>>
>>> If p_IdPais = 1 Then
>>>
>>> p_IdPais = 2
>>>
>>> Session("IdPais") = 2
>>>
>>> Else
>>>
>>> p_IdPais = 1
>>>
>>> Session("IdPais") = 1
>>>
>>> End If
>>>
>>> 'Set Cookie
>>>
>>> Dim ACookie As New HttpCookie("MyPageCountry")
>>>
>>> ACookie.Values("Pais") = p_IdPais
>>>
>>> ACookie.Expires = DateTime.MaxValue
>>>
>>> Response.Cookies.Set(ACookie)
>>>
>>> End Sub
>>>
>>>
>>> HELP APPRECIATED
>>> THANKS
>>>
>>>
>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>> message news:(E-Mail Removed)...
>>>> TCordian,
>>>>
>>>> If the buttons happen to be in a user control that is being added to
>>>> the page dynamically then give the control an ID by adding me.ID =
>>>> "MyControlIDHere" to the page load of the control.
>>>>
>>>> I can't tell you why this works exactly, but it does. If this isn't a
>>>> dynamically added control please show some source code and I'll see if
>>>> I can figure out what's wrong.
>>>>
>>>> --
>>>> Sincerely,
>>>>
>>>> S. Justin Gengo, MCP
>>>> Web Developer / Programmer
>>>>
>>>> www.aboutfortunate.com
>>>>
>>>> "Out of chaos comes order."
>>>> Nietzsche
>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>>I have a user control that contains 2 image buttons, when you click one
>>>>>of them, both must change the image source, the thing is that the first
>>>>>time you click any one of them the page appears to do a postbak, but
>>>>>the image source or the image displayed does not change until I click
>>>>>one of the images a second time, why dows it take 2 clicks for the user
>>>>>to "refresh"?
>>>>>
>>>>> TIA!
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
TCORDON
Guest
Posts: n/a
 
      10-25-2005
I got the image thing to work, now there is another problem, When the image
was clicked the usercontrol sets a session variable and a cookie, but there
are other usercontrols in the same page that read that session variable when
they load and depending on its value they load different information, the
problem is that it appears as if they load before the click event from the
image happens, the load when the imagebutton on the first usercontrol send
the postback.

HELP

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:%(E-Mail Removed)...
> Ok,
>
> Then two more questions...
>
> 1) How are you setting the image urls?
> 2) What are the image names?
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "TCORDON" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> No, Im not.
>>
>>
>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>> message news:(E-Mail Removed)...
>>> TCORDON,
>>>
>>> Just going through troubleshooting steps here...
>>>
>>> Are you using smart navigation?
>>>
>>> --
>>> Sincerely,
>>>
>>> S. Justin Gengo, MCP
>>> Web Developer / Programmer
>>>
>>> www.aboutfortunate.com
>>>
>>> "Out of chaos comes order."
>>> Nietzsche
>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> This usercontrol has 1 image button that is supposed to do the work,
>>>> this control is used for country selection between 2 countries. It also
>>>> has an <IMG> that shows the selected country (The imagebutton shows the
>>>> other country option) so when toy click the image button it is supposed
>>>> to change the <IMG> to show the newly selected country and at that time
>>>> change a cookie value and a session var value to hold the current
>>>> country ID, this should also refresh the page that contains the
>>>> usercontrol to show content according to the current selected country.
>>>>
>>>> The imagebutton_click event is coded as follows:
>>>>
>>>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e
>>>> As System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>>>
>>>> If p_IdPais = 1 Then
>>>>
>>>> p_IdPais = 2
>>>>
>>>> Session("IdPais") = 2
>>>>
>>>> Else
>>>>
>>>> p_IdPais = 1
>>>>
>>>> Session("IdPais") = 1
>>>>
>>>> End If
>>>>
>>>> 'Set Cookie
>>>>
>>>> Dim ACookie As New HttpCookie("MyPageCountry")
>>>>
>>>> ACookie.Values("Pais") = p_IdPais
>>>>
>>>> ACookie.Expires = DateTime.MaxValue
>>>>
>>>> Response.Cookies.Set(ACookie)
>>>>
>>>> End Sub
>>>>
>>>>
>>>> HELP APPRECIATED
>>>> THANKS
>>>>
>>>>
>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>>> message news:(E-Mail Removed)...
>>>>> TCordian,
>>>>>
>>>>> If the buttons happen to be in a user control that is being added to
>>>>> the page dynamically then give the control an ID by adding me.ID =
>>>>> "MyControlIDHere" to the page load of the control.
>>>>>
>>>>> I can't tell you why this works exactly, but it does. If this isn't a
>>>>> dynamically added control please show some source code and I'll see if
>>>>> I can figure out what's wrong.
>>>>>
>>>>> --
>>>>> Sincerely,
>>>>>
>>>>> S. Justin Gengo, MCP
>>>>> Web Developer / Programmer
>>>>>
>>>>> www.aboutfortunate.com
>>>>>
>>>>> "Out of chaos comes order."
>>>>> Nietzsche
>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>>I have a user control that contains 2 image buttons, when you click
>>>>>>one of them, both must change the image source, the thing is that the
>>>>>>first time you click any one of them the page appears to do a postbak,
>>>>>>but the image source or the image displayed does not change until I
>>>>>>click one of the images a second time, why dows it take 2 clicks for
>>>>>>the user to "refresh"?
>>>>>>
>>>>>> TIA!
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-25-2005
TCORDON,

Fixing this may require some re-tooling of your application.

If you have multiple controls all counting on the same values then I think
the safest way to do this is to set all of them only after the page load
finishes.

What you should do is create public subroutines in each control that can be
called from the page they are contained in. Put the code for each controls
changes into those subroutines. You can then reference each control just
like you would any other .NET control by declaring it in the codebehind of
the page the control is on.

The next step is to use the OnBubbleEvent to check for the button click from
the image button.

Then call each of the other control's setup subroutines from within the
OnBubbleEvent's code.


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TCORDON" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I got the image thing to work, now there is another problem, When the image
>was clicked the usercontrol sets a session variable and a cookie, but there
>are other usercontrols in the same page that read that session variable
>when they load and depending on its value they load different information,
>the problem is that it appears as if they load before the click event from
>the image happens, the load when the imagebutton on the first usercontrol
>send the postback.
>
> HELP
>
> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
> message news:%(E-Mail Removed)...
>> Ok,
>>
>> Then two more questions...
>>
>> 1) How are you setting the image urls?
>> 2) What are the image names?
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "TCORDON" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> No, Im not.
>>>
>>>
>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>> message news:(E-Mail Removed)...
>>>> TCORDON,
>>>>
>>>> Just going through troubleshooting steps here...
>>>>
>>>> Are you using smart navigation?
>>>>
>>>> --
>>>> Sincerely,
>>>>
>>>> S. Justin Gengo, MCP
>>>> Web Developer / Programmer
>>>>
>>>> www.aboutfortunate.com
>>>>
>>>> "Out of chaos comes order."
>>>> Nietzsche
>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> This usercontrol has 1 image button that is supposed to do the work,
>>>>> this control is used for country selection between 2 countries. It
>>>>> also has an <IMG> that shows the selected country (The imagebutton
>>>>> shows the other country option) so when toy click the image button it
>>>>> is supposed to change the <IMG> to show the newly selected country and
>>>>> at that time change a cookie value and a session var value to hold the
>>>>> current country ID, this should also refresh the page that contains
>>>>> the usercontrol to show content according to the current selected
>>>>> country.
>>>>>
>>>>> The imagebutton_click event is coded as follows:
>>>>>
>>>>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal e
>>>>> As System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>>>>
>>>>> If p_IdPais = 1 Then
>>>>>
>>>>> p_IdPais = 2
>>>>>
>>>>> Session("IdPais") = 2
>>>>>
>>>>> Else
>>>>>
>>>>> p_IdPais = 1
>>>>>
>>>>> Session("IdPais") = 1
>>>>>
>>>>> End If
>>>>>
>>>>> 'Set Cookie
>>>>>
>>>>> Dim ACookie As New HttpCookie("MyPageCountry")
>>>>>
>>>>> ACookie.Values("Pais") = p_IdPais
>>>>>
>>>>> ACookie.Expires = DateTime.MaxValue
>>>>>
>>>>> Response.Cookies.Set(ACookie)
>>>>>
>>>>> End Sub
>>>>>
>>>>>
>>>>> HELP APPRECIATED
>>>>> THANKS
>>>>>
>>>>>
>>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>>>> message news:(E-Mail Removed)...
>>>>>> TCordian,
>>>>>>
>>>>>> If the buttons happen to be in a user control that is being added to
>>>>>> the page dynamically then give the control an ID by adding me.ID =
>>>>>> "MyControlIDHere" to the page load of the control.
>>>>>>
>>>>>> I can't tell you why this works exactly, but it does. If this isn't a
>>>>>> dynamically added control please show some source code and I'll see
>>>>>> if I can figure out what's wrong.
>>>>>>
>>>>>> --
>>>>>> Sincerely,
>>>>>>
>>>>>> S. Justin Gengo, MCP
>>>>>> Web Developer / Programmer
>>>>>>
>>>>>> www.aboutfortunate.com
>>>>>>
>>>>>> "Out of chaos comes order."
>>>>>> Nietzsche
>>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>>I have a user control that contains 2 image buttons, when you click
>>>>>>>one of them, both must change the image source, the thing is that the
>>>>>>>first time you click any one of them the page appears to do a
>>>>>>>postbak, but the image source or the image displayed does not change
>>>>>>>until I click one of the images a second time, why dows it take 2
>>>>>>>clicks for the user to "refresh"?
>>>>>>>
>>>>>>> TIA!
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
TCORDON
Guest
Posts: n/a
 
      10-25-2005
Should that be on the OnBubbleEvent in the form or in the control that
changes the value all other controls reference?

Thanks

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:(E-Mail Removed)...
> TCORDON,
>
> Fixing this may require some re-tooling of your application.
>
> If you have multiple controls all counting on the same values then I think
> the safest way to do this is to set all of them only after the page load
> finishes.
>
> What you should do is create public subroutines in each control that can
> be called from the page they are contained in. Put the code for each
> controls changes into those subroutines. You can then reference each
> control just like you would any other .NET control by declaring it in the
> codebehind of the page the control is on.
>
> The next step is to use the OnBubbleEvent to check for the button click
> from the image button.
>
> Then call each of the other control's setup subroutines from within the
> OnBubbleEvent's code.
>
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "TCORDON" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I got the image thing to work, now there is another problem, When the
>>image was clicked the usercontrol sets a session variable and a cookie,
>>but there are other usercontrols in the same page that read that session
>>variable when they load and depending on its value they load different
>>information, the problem is that it appears as if they load before the
>>click event from the image happens, the load when the imagebutton on the
>>first usercontrol send the postback.
>>
>> HELP
>>
>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>> message news:%(E-Mail Removed)...
>>> Ok,
>>>
>>> Then two more questions...
>>>
>>> 1) How are you setting the image urls?
>>> 2) What are the image names?
>>>
>>> --
>>> Sincerely,
>>>
>>> S. Justin Gengo, MCP
>>> Web Developer / Programmer
>>>
>>> www.aboutfortunate.com
>>>
>>> "Out of chaos comes order."
>>> Nietzsche
>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> No, Im not.
>>>>
>>>>
>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>>> message news:(E-Mail Removed)...
>>>>> TCORDON,
>>>>>
>>>>> Just going through troubleshooting steps here...
>>>>>
>>>>> Are you using smart navigation?
>>>>>
>>>>> --
>>>>> Sincerely,
>>>>>
>>>>> S. Justin Gengo, MCP
>>>>> Web Developer / Programmer
>>>>>
>>>>> www.aboutfortunate.com
>>>>>
>>>>> "Out of chaos comes order."
>>>>> Nietzsche
>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> This usercontrol has 1 image button that is supposed to do the work,
>>>>>> this control is used for country selection between 2 countries. It
>>>>>> also has an <IMG> that shows the selected country (The imagebutton
>>>>>> shows the other country option) so when toy click the image button it
>>>>>> is supposed to change the <IMG> to show the newly selected country
>>>>>> and at that time change a cookie value and a session var value to
>>>>>> hold the current country ID, this should also refresh the page that
>>>>>> contains the usercontrol to show content according to the current
>>>>>> selected country.
>>>>>>
>>>>>> The imagebutton_click event is coded as follows:
>>>>>>
>>>>>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal
>>>>>> e As System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>>>>>
>>>>>> If p_IdPais = 1 Then
>>>>>>
>>>>>> p_IdPais = 2
>>>>>>
>>>>>> Session("IdPais") = 2
>>>>>>
>>>>>> Else
>>>>>>
>>>>>> p_IdPais = 1
>>>>>>
>>>>>> Session("IdPais") = 1
>>>>>>
>>>>>> End If
>>>>>>
>>>>>> 'Set Cookie
>>>>>>
>>>>>> Dim ACookie As New HttpCookie("MyPageCountry")
>>>>>>
>>>>>> ACookie.Values("Pais") = p_IdPais
>>>>>>
>>>>>> ACookie.Expires = DateTime.MaxValue
>>>>>>
>>>>>> Response.Cookies.Set(ACookie)
>>>>>>
>>>>>> End Sub
>>>>>>
>>>>>>
>>>>>> HELP APPRECIATED
>>>>>> THANKS
>>>>>>
>>>>>>
>>>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote
>>>>>> in message news:(E-Mail Removed)...
>>>>>>> TCordian,
>>>>>>>
>>>>>>> If the buttons happen to be in a user control that is being added to
>>>>>>> the page dynamically then give the control an ID by adding me.ID =
>>>>>>> "MyControlIDHere" to the page load of the control.
>>>>>>>
>>>>>>> I can't tell you why this works exactly, but it does. If this isn't
>>>>>>> a dynamically added control please show some source code and I'll
>>>>>>> see if I can figure out what's wrong.
>>>>>>>
>>>>>>> --
>>>>>>> Sincerely,
>>>>>>>
>>>>>>> S. Justin Gengo, MCP
>>>>>>> Web Developer / Programmer
>>>>>>>
>>>>>>> www.aboutfortunate.com
>>>>>>>
>>>>>>> "Out of chaos comes order."
>>>>>>> Nietzsche
>>>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>>>> news:(E-Mail Removed)...
>>>>>>>>I have a user control that contains 2 image buttons, when you click
>>>>>>>>one of them, both must change the image source, the thing is that
>>>>>>>>the first time you click any one of them the page appears to do a
>>>>>>>>postbak, but the image source or the image displayed does not change
>>>>>>>>until I click one of the images a second time, why dows it take 2
>>>>>>>>clicks for the user to "refresh"?
>>>>>>>>
>>>>>>>> TIA!
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-26-2005
It should be in the form.

Each control "bubbles" it's events up to the default form. Since you need to
make certain that all controls are loaded before you change them based on
your session variable you can do this from the main form they are contained
in since that form won't receive the bubbled event until all the controls
have been loaded.

To access the OnBubbleEvent you would use code like this:

Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
args As System.EventArgs) As Boolean
Try
Dim Control As System.Web.UI.Control

'---If you have more than one button that could trigger control
changes use a select case (otherwise an if/then would suffice
Select Case Control.ID
Case "[YourButtonIdHere]"
'---Here you can call the public subroutines you set up on
your controls
Call MyUserControl.Setup() '---You could either set your
session variables just before calling the subroutine or pass the necessary
information directly in.
Case "[AnyOtherButtonIDHere]"
'---Fire any code here
End Select
Catch ExceptionCaught As Exception
'---Hanle any exception here
End Try
End Function

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TCORDON" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Should that be on the OnBubbleEvent in the form or in the control that
> changes the value all other controls reference?
>
> Thanks
>
> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
> message news:(E-Mail Removed)...
>> TCORDON,
>>
>> Fixing this may require some re-tooling of your application.
>>
>> If you have multiple controls all counting on the same values then I
>> think the safest way to do this is to set all of them only after the page
>> load finishes.
>>
>> What you should do is create public subroutines in each control that can
>> be called from the page they are contained in. Put the code for each
>> controls changes into those subroutines. You can then reference each
>> control just like you would any other .NET control by declaring it in the
>> codebehind of the page the control is on.
>>
>> The next step is to use the OnBubbleEvent to check for the button click
>> from the image button.
>>
>> Then call each of the other control's setup subroutines from within the
>> OnBubbleEvent's code.
>>
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "TCORDON" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I got the image thing to work, now there is another problem, When the
>>>image was clicked the usercontrol sets a session variable and a cookie,
>>>but there are other usercontrols in the same page that read that session
>>>variable when they load and depending on its value they load different
>>>information, the problem is that it appears as if they load before the
>>>click event from the image happens, the load when the imagebutton on the
>>>first usercontrol send the postback.
>>>
>>> HELP
>>>
>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>> message news:%(E-Mail Removed)...
>>>> Ok,
>>>>
>>>> Then two more questions...
>>>>
>>>> 1) How are you setting the image urls?
>>>> 2) What are the image names?
>>>>
>>>> --
>>>> Sincerely,
>>>>
>>>> S. Justin Gengo, MCP
>>>> Web Developer / Programmer
>>>>
>>>> www.aboutfortunate.com
>>>>
>>>> "Out of chaos comes order."
>>>> Nietzsche
>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> No, Im not.
>>>>>
>>>>>
>>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
>>>>> message news:(E-Mail Removed)...
>>>>>> TCORDON,
>>>>>>
>>>>>> Just going through troubleshooting steps here...
>>>>>>
>>>>>> Are you using smart navigation?
>>>>>>
>>>>>> --
>>>>>> Sincerely,
>>>>>>
>>>>>> S. Justin Gengo, MCP
>>>>>> Web Developer / Programmer
>>>>>>
>>>>>> www.aboutfortunate.com
>>>>>>
>>>>>> "Out of chaos comes order."
>>>>>> Nietzsche
>>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>> This usercontrol has 1 image button that is supposed to do the work,
>>>>>>> this control is used for country selection between 2 countries. It
>>>>>>> also has an <IMG> that shows the selected country (The imagebutton
>>>>>>> shows the other country option) so when toy click the image button
>>>>>>> it is supposed to change the <IMG> to show the newly selected
>>>>>>> country and at that time change a cookie value and a session var
>>>>>>> value to hold the current country ID, this should also refresh the
>>>>>>> page that contains the usercontrol to show content according to the
>>>>>>> current selected country.
>>>>>>>
>>>>>>> The imagebutton_click event is coded as follows:
>>>>>>>
>>>>>>> Private Sub imgNewCountry_Click(ByVal sender As System.Object, ByVal
>>>>>>> e As System.Web.UI.ImageClickEventArgs) Handles imgNewCountry.Click
>>>>>>>
>>>>>>> If p_IdPais = 1 Then
>>>>>>>
>>>>>>> p_IdPais = 2
>>>>>>>
>>>>>>> Session("IdPais") = 2
>>>>>>>
>>>>>>> Else
>>>>>>>
>>>>>>> p_IdPais = 1
>>>>>>>
>>>>>>> Session("IdPais") = 1
>>>>>>>
>>>>>>> End If
>>>>>>>
>>>>>>> 'Set Cookie
>>>>>>>
>>>>>>> Dim ACookie As New HttpCookie("MyPageCountry")
>>>>>>>
>>>>>>> ACookie.Values("Pais") = p_IdPais
>>>>>>>
>>>>>>> ACookie.Expires = DateTime.MaxValue
>>>>>>>
>>>>>>> Response.Cookies.Set(ACookie)
>>>>>>>
>>>>>>> End Sub
>>>>>>>
>>>>>>>
>>>>>>> HELP APPRECIATED
>>>>>>> THANKS
>>>>>>>
>>>>>>>
>>>>>>> "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote
>>>>>>> in message news:(E-Mail Removed)...
>>>>>>>> TCordian,
>>>>>>>>
>>>>>>>> If the buttons happen to be in a user control that is being added
>>>>>>>> to the page dynamically then give the control an ID by adding me.ID
>>>>>>>> = "MyControlIDHere" to the page load of the control.
>>>>>>>>
>>>>>>>> I can't tell you why this works exactly, but it does. If this isn't
>>>>>>>> a dynamically added control please show some source code and I'll
>>>>>>>> see if I can figure out what's wrong.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Sincerely,
>>>>>>>>
>>>>>>>> S. Justin Gengo, MCP
>>>>>>>> Web Developer / Programmer
>>>>>>>>
>>>>>>>> www.aboutfortunate.com
>>>>>>>>
>>>>>>>> "Out of chaos comes order."
>>>>>>>> Nietzsche
>>>>>>>> "TCORDON" <(E-Mail Removed)> wrote in message
>>>>>>>> news:(E-Mail Removed)...
>>>>>>>>>I have a user control that contains 2 image buttons, when you click
>>>>>>>>>one of them, both must change the image source, the thing is that
>>>>>>>>>the first time you click any one of them the page appears to do a
>>>>>>>>>postbak, but the image source or the image displayed does not
>>>>>>>>>change until I click one of the images a second time, why dows it
>>>>>>>>>take 2 clicks for the user to "refresh"?
>>>>>>>>>
>>>>>>>>> TIA!
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
JSP: Session parameters vanish on refresh. How do I keep them on refresh? Per Magnus L?vold Java 1 10-08-2004 02:52 PM
How do i refresh a datagrid from a pop up window without having to refresh the whole page? Pkenty ASP .Net Web Controls 0 05-28-2004 07:06 AM
Problem with refresh button breaking automatic refresh brian lanning ASP .Net 0 07-29-2003 07:57 PM



Advertisments