473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Postback not working

CroCrew
564 Expert 512MB
I know that I should post my question in the asp.net forum but I did not want just anyone to answer my question. I want just the “Pros” answers. First off; I don’t want to use master pages. I hate them! Second I want to that everyone that posts a reply to this question in advance.

I have three “user controls” and on page (see below). The steps that I am trying to do and will not give up on till I get a solution. Everything is possible; just trying to rig it to work is the test.

Walk through: The “Default.aspx” page loads and within that page there are two “PlaceHolder”s. Both are pre-populated with a link (PlaceHolder01) and text (PlaceHolder02). When the link within “PlaceHolder01” (Link One) is clicked; on the postback “PlaceHolder01” gets a new user control injected within it and the verbage for “PlaceHolder01” is now “Link Two”. All this works so far.

Here is where the problem starts:

When you click on “Link Two” within “PlaceHolder01” the postback should change the value within “PlaceHolder02” with another user control. But it does not.

Anyone knows why? Or has a work around?

Thanks,
CroCrew~

Default.aspx
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.     <head runat="server">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <form id="form1" runat="server">
  9.             <div>
  10.                 Links:
  11.                 <asp:PlaceHolder runat="server" ID="PlaceHolder01">
  12.                     <a href="#" id="btnLinkOne" runat="server">Link One</a>
  13.                 </asp:PlaceHolder>
  14.                 <br />
  15.                 <br />
  16.                 <br />
  17.                 <br />
  18.                 Body:
  19.                 <asp:PlaceHolder runat="server" ID="PlaceHolder02">
  20.                     Welcome!
  21.                 </asp:PlaceHolder>    
  22.             </div>
  23.         </form>
  24.     </body>
  25. </html>
  26.  
Default.aspx.vb
Expand|Select|Wrap|Line Numbers
  1. Partial Class _Default
  2.     Inherits System.Web.UI.Page
  3.  
  4.     Protected Sub btnLinkOne_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLinkOne.ServerClick
  5.         btnLinkOne.Controls.Clear()
  6.         btnLinkOne.Controls.Add(LoadControl("WebUserControl.ascx"))
  7.     End Sub
  8. End Class
  9.  
WebUserControl.ascx
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="VB" AutoEventWireup="false" CodeFile="WebUserControl.ascx.vb" Inherits="WebUserControl" %>
  2. <a href="#" id="btnLinkTwo" runat="server">Link Two</a>
  3.  
WebUserControl.ascx.vb
Expand|Select|Wrap|Line Numbers
  1. Partial Class WebUserControl
  2.     Inherits System.Web.UI.UserControl
  3.  
  4.     Protected Sub btnLinkTwo_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLinkTwo.ServerClick
  5.         Page.FindControl("PlaceHolder02").Controls.Clear()
  6.         Page.FindControl("PlaceHolder02").Controls.Add(LoadControl("WebUserControl2.ascx"))
  7.     End Sub
  8. End Class
  9.  
WebUserControl2.ascx
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="VB" AutoEventWireup="false" CodeFile="WebUserControl2.ascx.vb" Inherits="WebUserControl2" %>
  2. <b>Cool!!</b>
  3.  
Oct 28 '09 #1

✓ answered by Frinavale

You have 2 user controls:
  • WebUserControl
  • WebUserControl2

They are related to one another.
You have stated that the Default.aspx page should manage of how they interact....

To do this I recommend using Events.

When the user clicks link2 in WebUserControl raise an event (maybe call it something like LinkClicked or something).

Implement a method that handles that event in your Default.aspx page which displays WebUserControl2.

-Frinny

2 2416
CroCrew
564 Expert 512MB
More information…

I just stepped through the code and when the btnLinkTwo link is click it never goes into the btnLinkTwo_ServerClick Protected Sub.

I did put a Page_Load event on WebUserControl.ascx.vb to see if the code behind page works and it did go into that sub.

Thanks again for any help,
CroCrew~
Oct 29 '09 #2
Frinavale
9,735 Expert Mod 8TB
You have 2 user controls:
  • WebUserControl
  • WebUserControl2

They are related to one another.
You have stated that the Default.aspx page should manage of how they interact....

To do this I recommend using Events.

When the user clicks link2 in WebUserControl raise an event (maybe call it something like LinkClicked or something).

Implement a method that handles that event in your Default.aspx page which displays WebUserControl2.

-Frinny
Oct 29 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mike Bridge | last post by:
Hi- I'm having some problems with postback (using .net 1.1 on XP Professional). All my postback links stop functioning after a while. After a certain point, the postback links suddenly do...
21
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script...
7
by: Anand | last post by:
Hi All, The postback on my desktop stopped working. I am trying to run the webapplication locally on my desktop and the Postback on my home page won't trigger on any of my dropdown selections. The...
7
by: Tim_Mac | last post by:
hi, using .net 2.0, i have a web form with lots of textboxes, drop-down-lists etc. There are lots of required field validators and regular expression validators. When i click the 'save' button,...
1
by: Jason | last post by:
I have a webpage that I've wrapped in an Atlas UpdatePanel. This page contains four textboxes, each with AutoPostBack set to true. The problem comes when someone edits the first box and tabs to...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
7
by: =?Utf-8?B?TWlrZSBMb2dhbg==?= | last post by:
My environment. .Net 2.0 VS2k5 SP1, IE6 (6.0.2900.2180) I have a web content page. The page will post back twice if I am running in debug mode. However if I run through the breakpoints fast...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.