Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to create a composite server control for a new project im working on and it looks simple enough to do. However I want the control to show up in the Design environment like a regular asp control. I know I have to add extra tags to the code for this to work. Does anyone know of any code samples that does this in vb.net? all samples I have found are c# or do not have this functionality.

 

thanks,

Josh

Posted
However I want the control to show up in the Design environment like a regular asp control.

Not quite sure what you meant by that:

1. If you mean that the control will be displayed in design time as what it should look like and not a grey box, then Custom Controls should do that. Unless you created an User Control (*.ascx). If you want to add a Cusom Control, you can add a new "Web Control Library" project to your solution or create a class that inheret from System.Web.UI.Control or System.Web.UI.WebControls.WebControl.

 

2. Or if you mean that the control will be displayed in the Toolbox (on the left), then:

i. Right click on one of the tabs (or create a new one)

ii. Choose "Customize Toolbox"

iii. Choose ".Net Framework Component" tab

iv. Click on Browse button and locate your *.dll or *.exe control file.

 

If you need help building a Custom Control, try here. Hope this helps.

Posted

I am refering to custom control. the one test control I made worked but in the IDE I got a grey box that said error on it. All the control was was a composite of a text box and a required field validator. Another problem I was having was when I put the control in the toolbox and tried to drag n drop it onto the form it did nothing except add a reference to my project....

 

thanks,

Josh

Posted

I made another simple control and this one gets a parser error. But I cannot see what is wrong with this...

 

Control code:

Imports System
Imports System.web
Imports System.Web.UI
Imports System.ComponentModel
Namespace MyControl
   Public Class testControl
       Inherits System.Web.UI.WebControls.WebControl

       Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
           writer.Write("<h1>Hello World<h1>")
       End Sub

   End Class
End Namespace

 

Page Code:

<%@ Register TagPrefix="JB" Namespace="MyControl" Assembly="testControl"%>

<JB:testControl runat="server"/>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...