473,756 Members | 7,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Postbacks in User Controls

(Second Try)

Greetings,

I have an asp.net web application that utilizes a User Control at the top of
the page.

My User Control contains a Server Control menu which will require postbacks.

I currently cannot get this to happen, but I know the functionality is
there. Can anybody offer me some advice or point me in the right direction
to get my postbacks working in User Controls?

My codebehind is in vb.net.

Thank you kindly for your help,

-Dave
Nov 18 '05 #1
5 1650
What do you mean when you say postbacks do not occur? Did you try to put
If(IsPostback) in your Page_Load of either web page or user control?
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Dave" <no****@yahoo.c om> wrote in message
news:Ok******** ******@TK2MSFTN GP15.phx.gbl...
(Second Try)

Greetings,

I have an asp.net web application that utilizes a User Control at the top of the page.

My User Control contains a Server Control menu which will require postbacks.
I currently cannot get this to happen, but I know the functionality is
there. Can anybody offer me some advice or point me in the right direction to get my postbacks working in User Controls?

My codebehind is in vb.net.

Thank you kindly for your help,

-Dave

Nov 18 '05 #2
Kumar,

Thanks for the response. To keep an example simple, say I have a User
Control with a button and a label in it. When the button is clicked, the
label's text changes to "The button has been clicked." This works fine in a
page, but when it is in a user control, the postback occurs, but the text in
the label does not change.

-Dave

"Kumar Reddi" <Ku********@REM OVETHIS.gmail.c om> wrote in message
news:e2******** ******@TK2MSFTN GP09.phx.gbl...
What do you mean when you say postbacks do not occur? Did you try to put
If(IsPostback) in your Page_Load of either web page or user control?
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Dave" <no****@yahoo.c om> wrote in message
news:Ok******** ******@TK2MSFTN GP15.phx.gbl...
(Second Try)

Greetings,

I have an asp.net web application that utilizes a User Control at the top

of
the page.

My User Control contains a Server Control menu which will require

postbacks.

I currently cannot get this to happen, but I know the functionality is
there. Can anybody offer me some advice or point me in the right

direction
to get my postbacks working in User Controls?

My codebehind is in vb.net.

Thank you kindly for your help,

-Dave


Nov 18 '05 #3

How you are trying to change the label's text in response to a button click
in the user control? Where did you put the code. Are you trying to change
the text of the correct url? Also did you enable the viewstate for the label
control and its parent, which is the userControl.?
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Dave" <no****@yahoo.c om> wrote in message
news:ue******** ******@TK2MSFTN GP12.phx.gbl...
Kumar,

Thanks for the response. To keep an example simple, say I have a User
Control with a button and a label in it. When the button is clicked, the
label's text changes to "The button has been clicked." This works fine in a page, but when it is in a user control, the postback occurs, but the text in the label does not change.

-Dave

"Kumar Reddi" <Ku********@REM OVETHIS.gmail.c om> wrote in message
news:e2******** ******@TK2MSFTN GP09.phx.gbl...
What do you mean when you say postbacks do not occur? Did you try to put
If(IsPostback) in your Page_Load of either web page or user control?
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Dave" <no****@yahoo.c om> wrote in message
news:Ok******** ******@TK2MSFTN GP15.phx.gbl...
(Second Try)

Greetings,

I have an asp.net web application that utilizes a User Control at the
top of
the page.

My User Control contains a Server Control menu which will require

postbacks.

I currently cannot get this to happen, but I know the functionality is
there. Can anybody offer me some advice or point me in the right

direction
to get my postbacks working in User Controls?

My codebehind is in vb.net.

Thank you kindly for your help,

-Dave



Nov 18 '05 #4
Kumar,

Yes, the viewstates are all enabled (the controls in the User Control as
well as the User Control itself).

The button that is in the user control fires this event:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Label1.Text = "The button has been clicked"
End Sub

That sub is stored in the vb codebehind of the user control
(template.ascx. vb)
My main asp.net page (that uses the User Control) is simply default.aspx.
When I run default.aspx and click on that button (the button that is in the
user control), the Label1.Text does not change.

Hopefully this should give you a good understanding of what my problem is.
Please let me know if I can help you understand my problem any further.

"Kumar Reddi" <Ku********@REM OVETHIS.gmail.c om> wrote in message
news:ey******** ******@TK2MSFTN GP11.phx.gbl...

How you are trying to change the label's text in response to a button
click
in the user control? Where did you put the code. Are you trying to change
the text of the correct url? Also did you enable the viewstate for the
label
control and its parent, which is the userControl.?
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Dave" <no****@yahoo.c om> wrote in message
news:ue******** ******@TK2MSFTN GP12.phx.gbl...
Kumar,

Thanks for the response. To keep an example simple, say I have a User
Control with a button and a label in it. When the button is clicked, the
label's text changes to "The button has been clicked." This works fine
in

a
page, but when it is in a user control, the postback occurs, but the text

in
the label does not change.

-Dave

"Kumar Reddi" <Ku********@REM OVETHIS.gmail.c om> wrote in message
news:e2******** ******@TK2MSFTN GP09.phx.gbl...
> What do you mean when you say postbacks do not occur? Did you try to
> put
> If(IsPostback) in your Page_Load of either web page or user control?
> --
> Kumar Reddi
> http://kumarreddi.blogspot.com
>
> "Dave" <no****@yahoo.c om> wrote in message
> news:Ok******** ******@TK2MSFTN GP15.phx.gbl...
>> (Second Try)
>>
>> Greetings,
>>
>> I have an asp.net web application that utilizes a User Control at the top > of
>> the page.
>>
>> My User Control contains a Server Control menu which will require
> postbacks.
>>
>> I currently cannot get this to happen, but I know the functionality is
>> there. Can anybody offer me some advice or point me in the right
> direction
>> to get my postbacks working in User Controls?
>>
>> My codebehind is in vb.net.
>>
>> Thank you kindly for your help,
>>
>> -Dave
>>
>>
>
>



Nov 18 '05 #5
"Dave" <no****@yahoo.c om> wrote in message
I have an asp.net web application that utilizes a User Control at the top of
the page.

My User Control contains a Server Control menu which will require postbacks.


Take a look at the HTML that's getting generated. I'm not certain,
but I'd bet that the __DoPostBack script is only set up to handle a
single form per page.

If so, you'll either need to stick the User Control inside of the main
form wherever it is used, or handle postbacks from it by hand.
Remember, at the end of the day, it's still just CGI programming. If
ASP.NET won't do something for you, there's nothing to stop you from
doing it yourself.

Good luck!
Jason

http://www.expatsoftware.com/
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3206
by: Jim Mitchell | last post by:
OK, have I come full circle.... ? 1) .NET with VS Studio seemed to be the answer to all my prayers. A) No more worries about coding for Netscape vs. IE. B) Quick Deployment C) All code in code behind. D) Go .NET So I re-wrote the whole application in .NET code behind.
4
1583
by: Ben Barter | last post by:
We have found a fundemental problem with the way that postbacks are handled. We have a page that has about 60 postback controls that are posted back to the server when the user clicks a link (LinkButton). The page takes about 5 seconds to render. A problem occurs when the user clicks the link, gets the page back to the browser, then immediately clicks the postback link again. In this situation the page has not finished rendering, but
4
6730
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle from all the various explanations/answers. I'm attempting the typical scenario... I create a variable number of controls at runtime based on parameters from a database.
6
4370
by: Neil | last post by:
Hi, I have an aspx page with a number of web controls on it and one of these is a cancel button. I want to check the page to see if the user has changed any of the controls, i..e typed some text in a textbox, changed a dropdown etc The reason I want to do this is when the user clicks cancel I want to notify them that their changes will be lost using a popup or something. My question is what is the best way to compare the page that...
3
3337
by: John | last post by:
I have an asp.net control which on the first Load of the page has a unique ID something like: _ctl0__ctl1_GroupName__ctl1_ControlName and after the first postback it changes to: _ctl0__ctl1_GroupName__ctl0_ControlName which is very bad, because I'm using javascript which relies on the
3
2270
by: Stu | last post by:
Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ctrl As AcceptOrCancel = CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel) PlaceHolder1.Controls.Add(ctrl)
1
2353
by: Gummy | last post by:
Hello, I am loading several user controls dynamically in OnInit() like this: ucListBoxSelections ucLocation = (ucListBoxSelections)LoadControl("UserControls/ucListBoxSelections.ascx");
1
2359
by: Khafancoder | last post by:
Hi guys, i'm trying to change all of page control's (root controls and inner controls) forecolor in PreRender event. it works fine but when a postback occures by detailsview command buttons, it fails... (i trace the code, it even executes in postbacks but control's forecolor don't change)
4
5635
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got around this problem I discovered that they're using Animations. I don't want to bloat my control with the Ajaxtoolkit's Animation stuff though. I guess I should tell you what the problem is. I have a TabStrip custom control. It's a Table that has...
0
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.