Question

javascript object required, unknown name

Asked by: mattegol

I've been asked to add a option in a dropdownlist in a form applikation. The dropdownlist is populated with other control types like textbox, textarea, radio, checkbox, and so on.. the dropdownlist has autopostback="true" and the selected control should trigger dynamically and be visible on the page, you can choose textbox 10 times for example.

My problem is: I have added the new control in the dropdownlist and replicated it like the others are built but now when the autopostback triggers i get these javascript errors: object required and unknown name, I don't have any code to show because it is at work, I'm hoping you can give me some advise on what may cause this.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-05-08 at 10:32:52ID24393205
Tags

asp.net

,

vb

,

javascript

Topics

VB Controls

,

Programming for ASP.NET

Participating Experts
1
Points
500
Comments
19

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. AutoPostBack
    Hi, can anyone help, when I use AutoPostBack=True in a dropdownlist all the other text boxes used in my form are reset and the information in them is cleared, anyone got a quick fix ??
  2. Javascript textbox or textarea
    hi all, i am using asp.net and javascript. I need to have a multiline textbox or textarea in my table. 1) when the application loads i need a generic message eg. "This is a test to show up in the textbox/textarea" so my question is how do i add text to and get...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: prairiedogPosted on 2009-05-08 at 11:57:14ID: 24339116

Please delete the duplicate question first.

 

by: mattegolPosted on 2009-05-08 at 12:08:52ID: 24339217

deleted!

 

by: prairiedogPosted on 2009-05-08 at 12:12:28ID: 24339256

Launch your app in FireFox, when the javascript error comes up, check the Error Console to see which line of code causes the error.

Without code, it is hard to debug.

 

by: mattegolPosted on 2009-05-08 at 12:17:12ID: 24339307

I tested it earlier in FireFox but no error was shown, the autopostback did not work though.

 

by: prairiedogPosted on 2009-05-08 at 12:21:59ID: 24339337

Hmm, strange.

You will need to post some code so we can understand your problem better.

 

by: mattegolPosted on 2009-05-08 at 12:47:09ID: 24339555

This is Page_Load section

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        '*********
        'first we check if the user is logged in. If not sent to LogIn page.
        'then we check that there is an eventid available. If not sent to register new event page.
        '****************
        Try
            If Session("Logged") = True Then
                'only proceed if event is not published
                If Session("EvPublished") <> "yes" Then
 
 
                    Dim strHeading As String
                    Dim lst As String = "" 'holds name of listbox to process
                    'strHeading = "Edit Reg Form"
                    'lblHeading.Text = strHeading
 
                    btnSave.Attributes.Add("onclick", "return ValErrorText();")
 
                    '******
                    'only show possibility of adding drop down options if that type of control is chosen
                    '******
                    dropoptions.Visible = False
                    radiooptions.Visible = False
                    regExpError.Visible = False
                    regExpMinMax.Visible = False
                    allocation.Visible = False
                    valrequired.Visible = True
                    reqErrorText.Visible = True
                    cctypelabel.Visible = False
                    ccNrLabel.Visible = False
                    ccDateLabel.Visible = False
                    ccCvcLabel.Visible = False
                    ccNrError.Visible = False
                    ccCVCError.Visible = False
                    chkShowCvC.Visible = False
                    txtarealabel.Visible = False
                    TextArea.Visible = False
                    help.Visible = True
                    frmlabel.Visible = True
                    frmEvalVal1Txt.visible = False
                    frmEvalVal2Txt.visible = False
                    frmEvalNrOptions.Visible = False
                        frmEvalQuestion.Visible = False
                        linkTextLabel.Visible = False
                        linkLabel.Visible = False
 
 
                    If Session("Eventid") > 0 Then
 
                        'check to see if a query string is coming in
                        'if so populate controls and put form in update mode
                        'this is fired from the dynamic edit buttons created on screen
                        If Not IsPostBack Then
                            If Request.QueryString.Count > 0 Then
                                Dim iControlid As Integer
 
                                iControlid = Request.QueryString("CID")
 
                                PopControls(iControlid)
                                ltlSaveFlag.Text = "Update"
                                ltlControlId.Text = iControlid
                                ddlControlType.Enabled = False
 
                            End If
                        End If
 
                        'build the preview at the bottom of page
                        BuildForm(Session("Eventid"), tdContainer, True, False)
 
 
                        If IsPostBack Then
 
                            Select Case ddlControlType.SelectedValue.ToUpper
 
                                Case "DROPDOWN"
 
                                    dropoptions.Visible = True
 
                                Case "RADIO"
                                    radiooptions.Visible = True
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
 
                                Case "CHECK"
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
 
                                Case "FIXED LENGTH", "MAX LENGTH"
                                    regExpError.Visible = True
                                    regExpMinMax.Visible = True
 
                                Case "NUMERIC"
                                    regExpError.Visible = True
 
                                Case "EMAIL"
                                    regExpError.Visible = True
 
                                Case "ALLOCATION"
                                    allocation.Visible = True
                                    regExpError.Visible = True
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
 
                                Case "SINGLEALLOCATION"
                                    allocation.Visible = True
                                    regExpError.Visible = True
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
 
                                Case "CREDITCARD"
 
                                    frmlabel.Visible = False
                                    cctypelabel.Visible = True
                                    ccNrLabel.Visible = True
                                    ccDateLabel.Visible = True
                                    ccCvcLabel.Visible = True
                                    ccNrError.Visible = True
                                    ccCVCError.Visible = True
                                    chkShowCvC.Visible = True
 
                                Case "SECTIONHEADER"
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
                                    help.Visible = False
 
                                Case "SUBSECTIONHEADER"
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
                                    help.Visible = False
 
                                Case "TEXTAREA"
                                    txtarealabel.Visible = True
                                    TextArea.Visible = True
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
                                    help.Visible = False
                                    frmlabel.Visible = False
 
                                Case "EVALUATION OPTIONS"
                                    radiooptions.Visible = False
                                    valrequired.Visible = False
                                    reqErrorText.Visible = False
                                    frmlabel.Visible = True
                                    frmEvalVal1Txt.Visible = True
                                    frmEvalVal2Txt.Visible = True
                                    frmEvalNrOptions.Visible = True
                                        frmEvalQuestion.Visible = True
 
                                    Case "LINK"
                                        'regExpError.Visible = True
                                        txtLinkText.Visible = True
                                        txtLink.Visible = True
                                        valrequired.Visible = False
                                        reqErrorText.Visible = False
                                        help.Visible = False
                                        frmlabel.Visible = False
 
                                End Select
 
 
                        End If

                                              
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:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:

Select allOpen in new window

 

by: mattegolPosted on 2009-05-08 at 12:57:50ID: 24339661

controls

<tr>
		<td class="header" colSpan="2">Edit Form
		</td>
	</tr>
	<TR>
		<td colSpan="2"><IMG height="10" src="../../images/shim.gif"></td>
	</TR>
	<TR>
		<TD class="label" width="200"><asp:label id="Label1" runat="server">Choose Control Type:</asp:label></TD>
		<TD class="label" width="400"><asp:dropdownlist id="ddlControlType" runat="server" Width="300" AutoPostBack="True" CssClass="Companylist"></asp:dropdownlist></TD>
	</TR>
	<tr id="radiooptions" runat="server">
		<td class="label" vAlign="top" width="200"><asp:label id="Label7" runat="server">Enter Control Options:</asp:label></td>
		<td width="400"><asp:textbox id="txtradvalue1" runat="server"></asp:textbox>&nbsp;&nbsp;
			<asp:textbox id="txtradvalue2" runat="server"></asp:textbox></td>
	</tr>
	<tr id="dropoptions" runat="server">
		<td class="label" vAlign="top" width="200"><asp:label id="Label6" runat="server">Enter Control Options:</asp:label></td>
		<td width="400">
			<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="400" border="0">
				<TR>
					<TD class="label" vAlign="top" width="270"><asp:textbox id="txtDropOption" runat="server"></asp:textbox>&nbsp;<A onclick="popListBox();" href="#"><IMG src="../../images/plus.gif" border="0"></A>
						&nbsp;<A onclick="DeleteListItem();" href="#"><IMG src="../../images/minus.gif" border="0"></A></TD>
					<TD class="label" width="170"><asp:listbox id="lstDropOption" runat="server" Width="170" CssClass="Companylist" SelectionMode="Multiple"></asp:listbox></TD>
				</TR>
			</TABLE>
		</td>
	</tr>
	<tr id="allocation" runat="server">
		<td>Enter Allocation Amt:</td>
		<td><asp:textbox id="txtAllocationAmt" runat="server" Width="50px"></asp:textbox></td>
	</tr>
	<TR id="regExpMinMax" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Min/Max Value:</TD>
		<TD width="400"><asp:textbox id="txtMin" runat="server" Width="50px"></asp:textbox>&nbsp;
			<asp:textbox id="txtMax" runat="server" Width="50px"></asp:textbox></TD>
	</TR>
	<TR id="regExpError" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Error Text.</TD>
		<TD width="400"><asp:textbox id="txtErrorText" runat="server" Width="300px" MaxLength="500"></asp:textbox></TD>
	</TR>
	<TR id="rptlabel" runat="server">
		<TD class="label" width="200"><asp:label id="Label5" runat="server">Enter Control Name:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtCtlName" runat="server" Width="300" MaxLength="50"></asp:textbox></TD>
	</TR>
	<TR id="frmlabel" runat="server">
		<TD class="label" width="200"><asp:label id="Label2" runat="server">Enter Label Text:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtControlLabel" runat="server" Width="300" MaxLength="500"></asp:textbox></TD>
	</TR>
	<!--Evaluation controls-->
	<TR id="frmEvalVal1Txt" runat="server">
		<TD class="label" width="200"><asp:label id="Label8" runat="server">Enter Left Text:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtEvalVal1Txt" runat="server" Width="300" MaxLength="500"></asp:textbox></TD>
	</TR>
	<TR id="frmEvalVal2Txt" runat="server">
		<TD class="label" width="200"><asp:label id="Label9" runat="server">Enter Right Text:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtEvalVal2Txt" runat="server" Width="300" MaxLength="500"></asp:textbox></TD>
	</TR>
	<TR id="frmEvalQuestion" runat="server">
		<TD class="label" width="200"><asp:label id="Label10" runat="server">Enter Question:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtEvalQuestion" runat="server" Width="300" MaxLength="500"></asp:textbox></TD>
	</TR>
	<TR id="frmEvalNrOptions" runat="server">
		<TD class="label" vAlign="top" width="200">How many options?:(2-7):</TD>
		<TD width="400"><asp:textbox id="txtEvalOptions" runat="server" Width="50px"></asp:textbox></TD>
	</TR>
	<!--Credit Card Fields-->
	<tr id="cctypelabel" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Type Label:</TD>
		<TD width="400"><asp:textbox id="txtCCtypeLabel" runat="server" Width="300px" MaxLength="500"></asp:textbox></TD>
	</tr>
	<tr id="ccNrLabel" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Nr Label:</TD>
		<TD width="400"><asp:textbox id="txtCCnrLabel" runat="server" Width="300px" MaxLength="100"></asp:textbox></TD>
	</tr>
	<tr id="ccNrError" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Nr Error:</TD>
		<TD width="400"><asp:textbox id="txtCCNrError" runat="server" Width="300px" MaxLength="100"></asp:textbox></TD>
	</tr>
	<tr id="ccDateLabel" runat="server">
		<TD class="label" vAlign="top" width="200">Enter Date Label:</TD>
		<TD width="400"><asp:textbox id="txtCCDateLabel" runat="server" Width="300px" MaxLength="100"></asp:textbox></TD>
	</tr>
	<tr id="chkShowCvC" runat="server">
		<TD class="label" vAlign="top" width="200">Show CVC?:</TD>
		<TD class="label" width="400"><asp:checkbox id="chkCVC" runat="server"></asp:checkbox></TD>
	</tr>
	<tr id="ccCvcLabel" runat="server">
		<TD class="label" vAlign="top" width="200">Enter CVC Label:</TD>
		<TD width="400"><asp:textbox id="txtCVCLabel" runat="server" Width="300px" MaxLength="100"></asp:textbox></TD>
	</tr>
	<tr id="ccCVCError" runat="server">
		<TD class="label" vAlign="top" width="200">Enter CVC Error:</TD>
		<TD width="400"><asp:textbox id="txtCCCvcError" runat="server" Width="300px" MaxLength="500"></asp:textbox></TD>
	</tr>
	<!--End of CreditCard Fields-->
	<!--Link Fields-->
	<tr id="linkTextLabel" runat="server">
		<TD class="label" vAlign="top" width="200">Link text:</TD>
		<TD width="400"><asp:textbox id="txtLinkText" runat="server" Width="300px" MaxLength="500"></asp:textbox></TD>
	</tr>
	<tr id="linkLabel" runat="server">
		<TD class="label" vAlign="top" width="200">Link:</TD>
		<TD width="400">
		    <asp:textbox id="txtLink" runat="server" Width="300px" MaxLength="500"></asp:textbox>
            <!--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtLink" ValidationExpression="((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)" runat="server" ErrorMessage="Ange en giltig adress" />-->
		</TD>
	</tr>
 
	<!--End of Link Fields-->
	<TR id="valrequired" runat="server">
		<TD class="label" width="200"><asp:label id="Label3" runat="server">Is it Required:</asp:label></TD>
		<TD class="label" width="400"><asp:radiobutton id="rbYes" runat="server" GroupName="grpYesNo" Text="Yes"></asp:radiobutton><asp:radiobutton id="rbNo" runat="server" GroupName="grpYesNo" Text="No"></asp:radiobutton></TD>
	</TR>
	<TR id="reqErrorText" runat="server">
		<TD class="label" width="200"><asp:label id="lblRequiredText" runat="server">Required Error Text:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtReqError" runat="server" Width="300" MaxLength="500"></asp:textbox></TD>
	</TR>
	<TR id="help" runat="server">
		<TD class="label" vAlign="top" width="200"><asp:label id="Label4" runat="server">Help Text:</asp:label></TD>
		<TD class="label" width="400"><asp:textbox id="txtHelpText" runat="server" Width="300" MaxLength="100" TextMode="MultiLine"></asp:textbox></TD>
	</TR>
	<tr id="txtarealabel" runat="server">
		<td class="label" colSpan="2"><asp:label id="lblTxtArea" Runat="server">Text:</asp:label></td>
	</tr>
	<tr id="TextArea" runat="server">
		<td class="label" colSpan="2"><asp:textbox id="txtTextArea" runat="server" Width="500" MaxLength="2000" TextMode="MultiLine"
				height="85"></asp:textbox></td>
	</tr>
	<TR>
		<td style="HEIGHT: 5px" colSpan="2"><IMG height="5" src="../../images/shim.gif">&nbsp;<INPUT id="lblList" type="hidden" runat="server"></td>
	</TR>
	<TR>
		<TD align="center" colSpan="2"><asp:button id="btnSave" runat="server" Text="Save"></asp:button>&nbsp;&nbsp;
			<asp:literal id="ltlSaveFlag" runat="server" Visible="False"></asp:literal><asp:literal id="ltlControlId" runat="server" Visible="False"></asp:literal></TD>
	</TR>
	<TR>
		<td colSpan="2"><IMG height="15" src="../../images/shim.gif">&nbsp;</td>
	</TR>
	<tr>
		<td class="header" colSpan="2">View Results
		</td>
	</tr>
	<TR>
		<td colSpan="2"><IMG height="10" src="../../images/shim.gif"></td>
	</TR>
</TABLE>
<table id="tblFormResult" cellSpacing="1" cellPadding="1" width="600" border="0">
	<tr>
		<td id="tdContainer" runat="server"></td>
	</tr>
</table>
                                              
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:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:

Select allOpen in new window

 

by: prairiedogPosted on 2009-05-08 at 13:00:36ID: 24339691

Strange, there is no JavaScript code in the code you provided. Do you have JavaScript code in ASPX file?

 

by: mattegolPosted on 2009-05-08 at 13:09:50ID: 24339783

the last code was from an user control

here is the aspx:

<%@ Register TagPrefix="uc1" TagName="ucMenu" Src="../EditControls/ucMenuEditEvent.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ucEditForm" Src="../EditControls/ucEditForm.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ucFooter" Src="../MainControls/ucFooter.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ucHeader" Src="../MainControls/ucHeader.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Inherits="RegisterForEvent.EditForm" CodeFile="EditForm.aspx.vb" %>
<HTML>
	<HEAD>
		<title>Edit Existing Event</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="../../Styles.css" type="text/css" rel="stylesheet">
		<script language="javascript">
		
function popListBox(){
 
				var lBox=document.getElementById('ucEditForm:lstDropOption');
				var tBox = document.getElementById('ucEditForm:txtDropOption');
				var tValue = tBox.value
				var iIndex = lBox.options.length;
				if (tValue == "") {
				alert("You need to enter a value");
				}
				else
				lBox.options[iIndex]=new Option(tValue,iIndex+1);
				lBox.options[iIndex].value=tValue
				}
				
function popAllocationListBox(){
 
				var lBox=document.getElementById('ucEditForm:lstAllocation');
				var tAllBox = document.getElementById('ucEditForm:txtAllocationItem');
				var tAmtBox = document.getElementById('ucEditForm:txtAllocationAmt');
				var tAllValue = tAllBox.value
				var tAmtValue = tAmtBox.value
				
				
				var iIndex = lBox.options.length;
				if ((tAllValue == "")||(tAmtValue == "")) {
				alert("You need to enter an allocation Item and Amount");
				return false
				}
				else
				var lstValue = tAllBox.value + " " + "(" + tAmtBox.value + ")"
				lBox.options[iIndex]=new Option(lstValue,iIndex+1);
				lBox.options[iIndex].value=lstValue
				}
				
	function SelectAllItems(sList)
				{
		var el = document.getElementById(sList)
		var intCount=el.options.length;
		for(i = 0; i < intCount;i++)
		{
			el.options(i).selected=true;
		}
		}
		
	function DeleteListItem()
		{
				var lBox=document.getElementById('ucEditForm:lstDropOption');
				var iSelIndex =lBox.selectedIndex
				if(iSelIndex ==-1){
				alert("You need to selected an item to delete");
				return false
				}
				else
				lBox.remove(iSelIndex);
		}
		
function ValErrorText()
				{
				var op = document.getElementById("ucEditForm_rbYes")
				var tx = document.getElementById("ucEditForm_txtReqError")
					if(op.checked==true){
 
						if (tx.value.length < 1)
							{
							alert("You must add a validation error message.")
							return false;
							}
							else
							{
							
							return true;
							}
							}
				}
		</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" onsubmit="SelectAllItems('ucEditForm:lstDropOption');"
			runat="server">
			<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="760" border="0">
				<TR>
					<TD colSpan="2"><uc1:ucheader id="ucHeader" runat="server"></uc1:ucheader></TD>
				</TR>
				<TR>
					<td colSpan="2"><IMG height="5" src="../../images/shim.gif"></td>
				</TR>
				<TR>
					<TD vAlign="top" width="160"><uc1:ucmenu id="ucMenu" runat="server"></uc1:ucmenu></TD>
					<td width="500"><uc1:uceditform id="ucEditForm" runat="server"></uc1:uceditform></td>
				</TR>
				<TR>
					<td colSpan="2"><IMG height="200" src="../../images/shim.gif"></td>
				</TR>
				<TR>
					<TD colSpan="2"><uc1:ucfooter id="ucFooter" runat="server"></uc1:ucfooter></TD>
				</TR>
			</TABLE>
		</form>
	</body>
</HTML>
                                              
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:

Select allOpen in new window

 

by: prairiedogPosted on 2009-05-08 at 13:23:42ID: 24339893

Line 93 is calling the JavaScript function by passing in 'ucEditForm:lstDropOption', but if 'ucEditForm:lstDropOption' is invisible, then when you do getElementById, you will get the JavaScript error as you mentioned in your question.

 

by: mattegolPosted on 2009-05-08 at 13:30:16ID: 24339952

So the controls can't be Visible="false" is that what you are saying?

 

by: prairiedogPosted on 2009-05-08 at 13:34:22ID: 24339982

Yes, if Visible="False", then ASP.NET will not render it to browser, then JavaScript will not find it because it does not exist in the HTML. you can check it by viewing the Page Source in your browser.

 

by: mattegolPosted on 2009-05-08 at 13:39:24ID: 24340019

But it has been working fine before in .net 1.1. Is there a difference in the later versions?

 

by: prairiedogPosted on 2009-05-08 at 13:45:14ID: 24340066

It should not be different. I don't know why it worked before but not working now. Mayber there are some changes in your application? Still launch your app in FireFox, then click Tools->Error Console to see the JavaScript error. Click the link of the error will show you which line is causing the JavaScript error.

 

by: mattegolPosted on 2009-05-08 at 13:54:13ID: 24340146

I made some of the controls visible and then it worked, but now I just have to figure out how many of them can be invisible..

 

by: mattegolPosted on 2009-05-08 at 14:39:43ID: 24340524

If I just set lstDropOption to visible all of the others work too, I just can't figure out why it worked before? Thanks, I'm almost there and i appreciate your help

 

by: prairiedogPosted on 2009-05-08 at 14:45:30ID: 24340572

Yes, it is because there is only one place calls the JavaScript: Line 93, which is eventually looking for lstDropOption. It has nothing to do with other controls.

 

by: prairiedogPosted on 2009-05-08 at 14:55:14ID: 24340636

There is a trick for hiding the control. Instead of using Visible="False" to hide it, you can do this:

lstDropOption.Attributes.Add("style", "display:none;")

To make it visible again:

lstDropOption.Attributes.Add("style", "display:block;")

This way, ASP.NET will still render the control to browser, but the style will hide the cotnrol. Since it exists in HTML, it will not cause JavaScript error.

 

by: mattegolPosted on 2009-05-09 at 06:04:45ID: 31579554

Thank you prairiedog

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...