|
Hi..
After adding header and footer usercontrols to all web pages in my asp.net 1.1 website some events are not fired any more (or may be not handled)like DataGrid events and DropDownList events(In many pages).I build the project many times but nothing changes.Could any one tell me Why adding header footer usercontrol cause this problem and how to solve it?.
-- modified at 20:18 Saturday 28th July, 2007
I am too late but i will never give up
|
|
|
|
|
I have been trying to create a user control that allows users to add and remove emails from their profiles and I havent been able to wrap my head around ViewState and Postbacks.
When the profile page is loaded there is one table row with 3 cells:
cell(0) contains two imagebuttons, one to add a new row and another to delete that particular row.
cell(1) contains a label
cell(2) contains a textbox to add the email
I want the user to click the add imagebutton to add a new row and the delete imagebutton to delete that particular row.
My problem is I cant seem to be able to add more than 2 rows. And if I click the buttons in the second row I don't seem to hit Click event handler for the clicked button.
Here is the code:
----------------------------------------------------
Imports System.Configuration
Public Class UC_Emails
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents plcEmailTable As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents tblUserEmails As System.Web.UI.WebControls.Table
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
AddEmailRow(maxEmails)
End Sub
#End Region
Dim maxEmails As Integer = CInt(ConfigurationSettings.AppSettings("MaxEmails"))
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
plcEmailTable.Controls.Add(tblUserEmails)
End Sub
Private Sub AddEmailRow(ByVal maxrows As Short)
If Not tblUserEmails.Rows.Count > maxrows Then
Dim eRow As New TableRow
'cells
Dim imgCell As New TableCell
Dim lblCell As New TableCell
Dim txtCell As New TableCell
Dim chkCell As New TableCell
'plus imagebutton
Dim plusImg As New ImageButton
plusImg.CssClass = "PlusMinusImage"
plusImg.ImageUrl = CType(Session("imagespath"), String).Replace(".", "~") & _
"btn_plus.jpg"
AddHandler plusImg.Click, AddressOf btnAdd_Click
'minus imagebutton
Dim minusImg As New ImageButton
minusImg.CssClass = "PlusMinusImage"
minusImg.ImageUrl = CType(Session("imagespath"), String).Replace(".", "~") & _
"btn_minus.jpg"
AddHandler minusImg.Click, AddressOf btnDelete_Click
'label
Dim lblEmail As New Label
lblEmail.Text = "Email:"
'text box
Dim txtEmail As New TextBox
txtEmail.CssClass = "EmailTextBox"
'primary check box
Dim chkPrimary As New CheckBox
chkPrimary.Text = "Primary email"
'add itrems to cells
imgCell.Controls.Add(plusImg)
imgCell.Controls.Add(minusImg)
lblCell.Controls.Add(lblEmail)
txtCell.Controls.Add(txtEmail)
chkCell.Controls.Add(chkPrimary)
'add cells to row
eRow.Cells.Add(imgCell)
eRow.Cells.Add(lblCell)
eRow.Cells.Add(txtCell)
eRow.Cells.Add(chkCell)
tblUserEmails.Rows.Add(eRow)
End If
End Sub
Private Sub DeleteEmailRow(ByVal sender As Object, ByVal remaminingRows As Integer)
If Not tblUserEmails.Rows.Count = 1 Then
Dim btnClicked As ImageButton = CType(sender, System.Web.UI.WebControls.ImageButton)
Dim row As TableRow
Dim cell As TableCell
cell = CType(btnClicked.Parent, TableCell)
row = cell.Parent
tblUserEmails.Rows.Remove(row)
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
AddEmailRow(maxEmails)
End Sub
Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
DeleteEmailRow(sender, tblUserEmails.Rows.Count)
End Sub
End Class
----------------------------------------------------------------
Please help in pointing out where I'm getting it wrong
-- modified at 13:21 Saturday 28th July, 2007
|
|
|
|
|
Viewstate is applied to the page's controls between Init and Load, so if you dynamically change your control in Page_Load, Viewstate won't be applied to them, and the page won't know what event caused the postback, and your event won't fire.
if you do this:
plcEmailTable.Controls.Add(tblUserEmails)
in PageInit instead, it should work.
-- modified at 13:53 Saturday 28th July, 2007
Duh, sorry, forget that. I see you're already doing your dynamic creation in PageInit. I read it too quickly.
|
|
|
|
|
If I add a dynamic control inside a user control in the UserControl's Page.Init method, and acoording to how I understand this the user control is loaded after the containing page's Load event ; how can i be able to add dynamic control on the user control into the containing page's ViewState???
|
|
|
|
|
I've done something very similar adding user controls to user controls, and the child user control's Init is fired as soon as it is added to the parent user control. It should be the same for Webcontrols.
I'm afraid I don't have any code in front of me, but will Monday, if you're still stuck by then I can paste some.
The best way to get the sequence of events firing is to set a breakpoing at every Init and Load in the hierarchy.
|
|
|
|
|
thanks, I'm still stuck though!!
|
|
|
|
|
Hello,
I want to iterate throught out the page controls and identify its type(button,textBox,.....etc) to set the text property but I can't.I've used this code
foreach (Control c in this.Controls)
{
Label1.Text = c.GetType().ToString();
}
but it doesn't work as expected.
thanks.
Dad
|
|
|
|
|
What do you expect that code to do, then?
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello Everyone,
I want to run my uploaded videos in realplayer or quicktime or mediaplayer
in my program My videos can be flash files or anything else
Thnx & Regards
Manoj Bisht
|
|
|
|
|
Hello There,
I have technical problem in with web project.
I'm trying to pass form data (hidden fields) to a url without redirecting to the page.
In other words, lets suppose my web project has 2 files 1.aspx and 2.aspx.
A user submits a form on 1.aspx and the page navigates to 2.aspx. But before navigating to 2.aspx I'm validating the user inputted data. After the validation I need pass the status of validation(Valid or Invalid data) to an external url lets suppose http://somewebsite.com/3.aspx.
The posting of data to http://somewebsite.com/3.aspx has to happen asyncronously behind the scene so that user navigates from 1.aspx to 2.aspx.
Could anyone please help me...any reference to any articles will be of great help.
Thanks!
Amit.
Cheers!
Amit.
|
|
|
|
|
|
Hi Bardly,
Thanks for the prompt answer. however I have explored AJAX as one of the options to achieve the solution to my problem but not successful in doing it.
I got to pass the data to 3.aspx page on the load of 2.aspx page.
Would you suggest me to create an event to fire the Ajax code(which intern passes the data to 3.aspx) and I would still load 2.aspx as expected behaviour??
Cheers!
Amit.
|
|
|
|
|
Yes, I can't think of a way to do what you want in the Load event of 2.aspx, so I was thinking of firing off the Ajax request in 1.aspx, just before posting to 2.aspx, and the Ajax request keeps 3.aspx happy and the normal post keeps 2.aspx happy.
|
|
|
|
|
hi everyone
I have used hyperlink to show ModalPopup Panel through AJAX Toolkit ModalPopupExtender.
Hyperlink is image only but i have assigned no targeUrl but associted with ModalPopupExtender.
Hyperlink image shows ModalPopup panel very well but doesn't change the cursor from pointer. Please tell me how i can solve this problem?
Thank you.
|
|
|
|
|
Hi all,
There is a html page which has a html table with some and having bgcolor like 'red','yellow'.
When I print this document with color printer.In print out i do not get any color.
For color i have also used images as background in , but i am not getting any color in print out.
Please give some suggestions.
Thank You.
"Every thing matters in this world but what you think,it matters more.
When thinking changes,the whole world changes."
|
|
|
|
|
In your Internet Explorere go:
Tools->Internet Options->Advanced (tab) ->check Print background colors and images
I Love SQL
|
|
|
|
|
hi everyone
please give me hint how i can do following:
I have inserted data into database using textboxes and database gets updated. Each record contains 5 fields. When I submit data from textboxes I want next page appear and show data.
But wait ......... i need each record as below
Name: abc
address: def street
phone: 1234
email: a11111@gmail.com
above is one record.
I want to if i feed new data in form text boxes. This new page show block of data of each record (new at the top) as given above.
Please guide me how can i do that ... if any article in this regard on code project please mention.
Thank You.
|
|
|
|
|
Hi..
Hi, I am trying to use couple of server controls in my master page and I need to identify the same at the client side(javascript). But in ASP .NET2.0 the server controls are appended with "ctl00_ctl00_" to the control id. How can I solve this problem.
Thanks
Mahesh.J
|
|
|
|
|
You want the .ClientID So on the server side you have code to set a client side variable = myControl.ClientID
something like:
Dim JSString As String = "var myControlID = " & myControl.ClientID & ";"
and on the client side you can refer to myControlID.
-- modified at 12:35 Saturday 28th July, 2007
(and obiously you have to Register that JSString so it shows up on the client side)
|
|
|
|
|
Using VS2005 with SP/1 on XP Pro...
I have a aspx/aspx.cs file pair. When I rebuild the website, I get the following error:
error ASPNET: Make sure that the class defined in this code file matches the "inherits" attribute, and that it extends the correct base class (e.g. Page or UserControl).
Here's the "inherits" line in the "erboard_dashboard.aspx" file:
Inherits="erboard_dashboard"
and here's the class definition in the "erboard_dashboard.aspx.cs" file:
public partial class erboard_dashboard : CBasePage
As you can dsee, everything matches.
The CBasePage base class is there in the project, and the class name is highlighted to inidcate that the IDE knows where it is.
What am I missing?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've seen this happen when the code behind doesn't define a namespace. If you don't put the code in a namespace, I think the folder names can be prepended to the class name. Try putting a namespace, any namespace, around the class, and then fully qualify it in the asp. So
ASPX:
inherits="JohnRocks.erboard_dashboard
.cs:
namespace JohnRocks
{
class erboard_dashboard : CBasePage
{
and so on. Also, try removing the _ from the class name, if that doesn't work. .NET uses the _ to create class names that include the names of folders, perhaps that is an issue....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i want to create pop up window in my windows forms through code.im using c#. is there any code for it??
software student
|
|
|
|
|
If you're using Windows Forms, why are you asking in the ASP.NET forum ? Assuming you mean windows forms, you really need to buy a book and read it, this is a very straightforward question. You create a dialog class, create an instance, and call ShowDialog on it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am using ASP.NET with Infragistics for my application....
In the UltraWebGrid, when i click the values in the row should get populated into their appropriate textboxes there...
I am new to Infragistics and need help from someone here...
Thanx in Advance....
SAJAN A PILLAI
C#.NET Programmer
TELESOFT INDIA PVT LTD...
BANGALORE
|
|
|
|
|
Dear all,
I am using asp.net2.0,C# , SQl2000.
I am using checkboxlist(whose enableviewstate is true). I access its value(ie item selected) first button click it work fine but on second button click event . it does not hold selected item value.
Please guide me
thanks
imaran khan
|
|
|
|