CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/21/2004 7:35:28 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
samoiz
Asp.Net User
Problem with Inserting Data Using usercontrols3/21/2004 7:35:28 AM

0/0

Dear All,

This is the Code of my business object used to insert AddressBook Details into db

-------------InsertData.VB-------------------------------------------------


Option Explicit
Option Strict

Imports system
Imports system.Data
Imports system.Data.SqlClient

NameSpace InsertData

Public Class Insert

Public Sub Addrec(val1 as String,val2 as String)

Dim strc as string
strc = "server=sedcosrv2;database=Master;uid=sa;pwd="



Dim strsql as String = "INSERT INTO address_book (Name,Email) VALUES ('" & val1 & "','" & val2 & "')"

Dim MyConn as New sqlConnection(strc)
Dim cmd as New SqlCommand (strsql, MyConn)
MyConn.Open()
cmd.ExecuteNonQuery()
MyConn.Close()


End Sub

End Class


End Namespace

-------------------------------------------------------------------

This was sucessfully compiled and dll was stored in Bin Folder. and assembly reference was added in web.config


----------------------------Addressbook.ascx-------------------


<%@ Control Language="VB" %>
<%@ import Namespace="InsertData" %>
<script runat="server">

public sub button1_Click(Sender as Object, e as Eventargs)

Dim Name,email,comments

Name = Textbox1.Text
Email = Textbox2.Text
Comments = Textbox3.Text

Dim inst as new Insert()

inst.Addrec(Name,Email)

Response.write ("Record Added")
End Sub


public sub button2_Click(Sender as Object, e as Eventargs)

Textbox1.Text = ""
Textbox2.Text = ""
Textbox3.Text = ""

End Sub

</script>
<table id="AutoNumber1" style="BORDER-COLLAPSE: collapse" bordercolor="#0066cc" height="407" cellspacing="0" cellpadding="0" width="800" border="1">
<tbody>
<tr>
<td bgcolor="#0066cc">
</td>
<td bgcolor="#0066cc">
</td>
</tr>
<tr>
<td bordercolor="#0066cc" width="100" bgcolor="#0066cc" rowspan="4">
</td>
<td height="20" rowspan="5">
<p align="center">
<font face="Arial" size="2"><img alt="Genesis Media Group" src="Images\bann.gif" align="center" /></font>&nbsp;
</p>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td style="FONT-WEIGHT: bold; FONT-SIZE: larger; COLOR: white; FONT-STYLE: normal; FONT-FAMILY: Arial; FONT-VARIANT: small-caps; TEXT-DECORATION: underline" bgcolor="#0066cc">
Sign In Address Book</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td style="FONT-WEIGHT: bold; FONT-SIZE: larger; COLOR: white; FONT-STYLE: normal; FONT-FAMILY: Arial; FONT-VARIANT: small-caps; TEXT-DECORATION: underline" bgcolor="white">
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td style="FONT-SIZE: x-small; COLOR: black; FONT-FAMILY: Arial" border="0">
&nbsp;Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td style="FONT-SIZE: x-small; COLOR: black; FONT-FAMILY: Arial">
&nbsp;Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td style="FONT-SIZE: x-small; COLOR: black; FONT-FAMILY: Arial">
&nbsp;Comments</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;<asp:TextBox id="TextBox3" runat="server" TextMode="MultiLine" Width="235px" Height="109px"></asp:TextBox>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
</td>
</tr>
<tr>
<td bgcolor="#0066cc">
</td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button id="Button1" runat="server" Text="Submit" Font-Names="Arial" Font-Size="X-Small" ForeColor="White" BackColor="#0066CC" BorderColor="#0066CC"></asp:Button>
&nbsp;&nbsp;&nbsp; &nbsp;<asp:Button id="Button2" runat="server" Text="Clear" Font-Names="Arial" Font-Size="X-Small" ForeColor="White" BackColor="#0066CC" BorderColor="#0066CC"></asp:Button>
</td>
</tr>
<tr>
<td width="30" bgcolor="#0066cc" height="420">
</td>
<td width="500" bgcolor="white">
<p>
</p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p style="FONT-SIZE: x-small; COLOR: black; FONT-FAMILY: Arial" align="justify">
</p>
</blockquote>
<p>
</p>
</td>
</tr>
</tbody>
</table>
---------------------------------------------------------------------------------------


addressbook.aspx -- using this user will sign in his details and record will be updated in database.


-----------------------------/// addressbook.aspx ///---------------------------------

<%@Register TagPrefix="project" TagName="Header" src="Header.ascx" %>
<%@Register TagPrefix="project" TagName="Body" src="addressbook.ascx" %>
<%@Register TagPrefix="project" TagName="Footer" src="footer.ascx" %>

<%@ Page language="VB" %>

<script runat="server">
' Insert page code here
'
</script>

<html>
<head>
</head>
<body topmargin="1" leftmargin="1">
<Project:Header runat="server" />

<Project:Body runat="server" />

<Project:Footer runat="server" />
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html>

-------------------------------------------------------------------------

When iam accessing addressbook.aspx this is the error thrown


Server Error in '/dot' Application.
--------------------------------------------------------------------------------

Control '_ctl1_TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Control '_ctl1_TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.


What might be the Problem?

Any Help will be highly appreciated.

Thanks

Syed Moiz..


master4eva
Asp.Net User
Re: Problem with Inserting Data Using usercontrols3/21/2004 8:57:16 AM

0/0

Do what is instructed - insert the text boxes into a serverside form. So, your page should look like this:

<%@Register TagPrefix="project" TagName="Header" src="Header.ascx" %>
<%@Register TagPrefix="project" TagName="Body" src="addressbook.ascx" %>
<%@Register TagPrefix="project" TagName="Footer" src="footer.ascx" %>

<%@ Page language="VB" %>

<script runat="server">
' Insert page code here
'
</script>

<html>
<head>
</head>
<body topmargin="1" leftmargin="1">
<form runat="server">
<Project:Header runat="server" />

<Project:Body runat="server" />

<Project:Footer runat="server" />
<!-- Insert content here -->
</form>
</body>
</html>

-- Justin Lovell
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET for Web Designers Authors: Peter Ladka, Pages: 648, Published: 2002
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Beginning ASP.NET 2.0 with C# Authors: Chris Hart, John Kauffman, David Sussman, Chris Ullman, Pages: 735, Published: 2006
Visual Basic .NET Developer's Guide to ASP.NET, XML, and ADO.NET Authors: Jeffrey P. McManus, Chris Kinsman, Pages: 592, Published: 2002
MCAD/MCSD Training Guide (70-315): Developing and Implementing Web Applications with Visual C# and Visual Studio. NET Authors: Amit Kalani, Pages: 1200, Published: 2002
Cocoa Recipes for Mac OS X: The Vermont Recipes Authors: Bill Cheeseman, Apple Computer, Inc, Pages: 780, Published: 2003
ASP. Net Development with Dreamweaver Mx: Ryan Parnell, Joel Martinez Authors: Ryan Parnell, Joel Martinez, Pages: 320, Published: 2002
Programming ASP.NET: Building Web Applications and Services Using C and VB.NET. Authors: Jesse Liberty, Dan Hurwitz, Pages: 988, Published: 2003
The Visual Basic Object and Component Handbook Authors: Peter Vogel, Pages: 668, Published: 2000
Professional Web Parts and Custom Controls with ASP.NET 2.0 Authors: Peter Vogel, Pages: 449, Published: 2005

Web:
Updating values using UserControl/FormTemplate Population/data editing with XmlDataSource control. CommandItem ... Insert/ Update/Delete records > Update records > Updating values using UserControl/ ...
Inserting values using UserControl/FormTemplate Population/data editing with XmlDataSource control. CommandItem ... Inserting values using UserControl/FormTemplate, Send comments on this topic. ...
Problems with the Cache and UserControls - ASP.NET Forums using (System.Data.SqlClient.SqlConnection con = new System. ... as i said above i have the same problem using cache.insert (i used the same ...
How to Insert Data (ADO.NET Data Services/Silverlight) Client library can insert data into ADO.NET Data Services. ... The data grid displays data by using a data binding scenario similar to that implemented in ...
ASP.NET For Developers Part 2 Duplicate User Controls · Nested User Controls · Using Nested Controls · Traps to Avoid. Section F: Caching Data · Cache.Add vs. Cache.Insert ...
CodeProject: WebParticles: Developing and Using Web User Controls ... Using Web User Controls in SharePoint WebParts; Author: Tony Rabun, MCITP; ... and I've been trying to modify the example in order to insert data into a SQL ...
ASP.NET MVC: Using UserControls Usefully - pedrocorreia.net Inserting data into a Spreadsheet ... Construir um simples Captcha . ... http:// blog.wekeroad.com/2008/01/07/aspnet-mvc-using-usercontrols-usef. ...
C# Bits: Dynamic Data Custom Pages: Dynamic/Templated Grid with ... Oct 5, 2008 ... Dynamic Data Custom Pages: Dynamic/Templated Grid with Insert (Using ListView). These articles are now under the title of Custom ...
Please help me.... Problem with XtraGrid not showing Data ... I am successful in showing the comboboxedit usercontrol with data ... I need to insert this data into the database and get its new identity. ...
Norton SystemWorks Premier! Its user controls/functions/install ... Insert your Premier disk and click on install, settle back in a ... zero problems with any data losses on all but one computer and it was quickly recovered. ...




Search This Site:










objectlist control from mobile controls

custom control with multiple properties of collection type

godaddy hosting and asp.net 2.0 + atlas

how? have thmeable url's in custom control.

dhtml menu control like

custom calender control

datagrid web ocntrol

[resolved] need windows/ms sql host w/vps and reselling w/support 4 my clients

using a custom nav control in all my pages

building auto-validated textbox using inheritance

composite control template and designer

user controls in templates

creating a tab control using ie controls,not getting it in correct form

maintaining viewstate in custom control based on dropdown list

please help me thanks

does anyone know how to call external web services on godaddy.com

user control linking to a css

adding my control icon to the assembly, how !!

custom dataadapter component

advice re hosting company

skip code when in design view

custom collection editor's problem

custom designeractionlists

displaying a uri in the property grid

slide control needed

want make a control that can nest other controls

google toolbar, yahoo toolbar, how about my toolbar ?

getting a control as xml

button is not working

browsers refresh is considered a postback after an itemcommand event

  Privacy | Contact Us
All Times Are GMT