System.web.UI doesn't work in VB.Net Form?

 Hi, I downloaded a little example recently and tried converting it to VB.Net.  Surprisingly I found that while my VB Web projects and CSharp Windows Form projects work with System.web.UI, VB Windows Forms don't seem to.

 Is there any way I can use System.web.UI features with a windows form?

 This is the code I'm trying to convert to VB:  

using System.IO;
using System.Web.UI.WebControls;
using System.Web.UI;

// render the DataGrid control to a file
using(StreamWriter sw = new StreamWriter(textBox1.Text))
{
using(HtmlTextWriter hw = new HtmlTextWriter(sw))
{
grid.RenderControl(hw);
}
}
 
Thanks, Michael 
 

It's all in the tree price...
0
MikeMackey
2/6/2009 11:23:15 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies
1528 Views

Similar Articles

[PageSpeed] 47

 Hi Mike!

check for the references of your project that is you've added System.Web in the references of your project. if not then add reference of System.Web to your project and then try to use it.

 

i think this will work for you...

 

 

__________________________________________________________________________

Don't forget to mark as answer if you got whatever you were looking for...

0
exorbitant
2/7/2009 6:00:41 AM
You can not use ASP.Net controls in WinForms application. First those, those controls render HTML. Second they work under HttpContext.... and so on. There is a wonderful datagrid available in winforms. Why would you want to use the one from web controls?
 
 
 
<MikeMackey> wrote in message news:2922867@forums.asp.net...

 Hi, I downloaded a little example recently and tried converting it to VB.Net.  Surprisingly I found that while my VB Web projects and CSharp Windows Form projects work with System.web.UI, VB Windows Forms don't seem to.

 Is there any way I can use System.web.UI features with a windows form?

 This is the code I'm trying to convert to VB:  

using System.IO;
using System.Web.UI.WebControls;
using System.Web.UI;

// create the DataGrid and perform the databinding
System.Web.UI.WebControls.DataGrid grid = new System.Web.UI.WebControls.DataGrid();
grid.HeaderStyle.Font.Bold = true;
grid.DataSource = data;
grid.DataMember = data.Stats.TableName;
grid.DataBind();

// render the DataGrid control to a file
using(StreamWriter sw = new StreamWriter(textBox1.Text))
{
	using(HtmlTextWriter hw = new HtmlTextWriter(sw))
	{
		grid.RenderControl(hw);
	}
}
 
Thanks, Michael 
 

It's all in the tree price...

http://forums.asp.net/p/1381496/2922867.aspx#2922867

0
bitnbytes
2/7/2009 1:10:03 PM

 Hi,

 Yes I tried System.Web, doesn't import the .UI after it which is the problem.

 Bitnbytes - That was my first thought, I guess what seemed odd to me is that Csharp windows forms would still work with it where VB windows forms would not.  I think I may just rewrite the page in csharp for it to work, but if I could have found a way for it to work in vb.net it would have been preferrable.

Also the datagrid isn't what I need, it's the HTMLWriter option.  With that I can write my datatables to excel with much less effort than would be required otherwise, and I don't need excel imports to do it.

 Thanks for your thoughts.

 


It's all in the tree price...
0
MikeMackey
2/7/2009 3:40:57 PM
Reply:

Similar Artilces:

Cann't add the reference ' System.Web.UI' from ".NET"
Cann't add the reference ' System.Web.UI' from ".NET",and i can n't find the file "System.web.UI.dll" from the "C:\WINDOWS\Microsoft.NET\Framework",so anyone can help me solve it thanks there is a no-footbird.the wind is its nest.it never stops flying until it dies... System.Web.UI is namespace, not an assembly. Add "System.Web.dll" and that will include System.Web.UI.Cheers,       Kevin JonesMy Blog Is your project a web project? To me, it looks like missing system.web.dll in your reference I think you need to reference system.web in the References...

WDP for VS2008 still doesn't allow web.config file section replacement of 'System.Net'
There were a series of posts on various blogs about the VS 2005 version of the WDP not allowing replacement of the 'System.Net' section. This was a rather significant oversight, in my opinion, as the three parts of web.config you would most likely want to replace would be appSettings for site specific attributes, connectionStrings for the proper database configuration, and System.Net to set up site-generated email. That being said, there was talk in the forums about fixing for the next release. Indeed, in the release notes for WDP for 2008 there was mention of fixes for config file u...

after installing web matrix VB.NET web page don't work
I just started with ASP.NET in VB.NET. I had developed a simple web page and it worked fine. Then I installed web matrix and started playing with it. When I go back to VB and try to run the program (that worked before) I get an error: "Unable to start debugging on the web server. Could not start ASP.NET or ATL server debugging." How do I get VB.NET to working again? I'm not sure why your existing Web application don't work after the installation of Web Matrix, as they can live without conflict in fact, did you try to look for an answer from the support.microsoft.com about the ...

Can't get the Web Controls to work.. The Build.Bat file doesn't work? HELP>> ARGGG>.
Hi.. I was wanting to use the IE Web Controls, the Tab Strip, etc, and play with it.. Since I have IIS 5, I thought I'd copy them there using the Read me.txt instructions and then copy to a dev server that I use at a web host.. Well, everything worked except the Build file doesn't build the Microsoft.UI.Webcontrols.DLL file? When I try to run it by double clicking on it, it runs really fast in  the DOS window, but I can't see what it says and it closes.. So I tried to do so manually and I received an error that the "cse.exe is not recognized as an internal or external command or batch...

.NET Remoting
Hi,I'm trying to write Remote server object , when I write:using System.Runtime.Remoting.Channel.TcpIt looks like this namespace doesn't exist and I can't use instances of objects in this name space as I used in .NET 1.1When I look at the documentation, it looks like there is no change in the syntex or methodology.Can some one please help me.all the best,el System.Runtime.Remoting.Channels.Tcp...

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

vb.net Directory.Exists doesn't work
Hi everybody, I have a problem that might look stupid,  but I really don't know why its not working. I've got a web service written in vb.net and the web service is sitting on one server doing manipulation on another server. What I'm trying to do is to check if a directory exists on the server before I copy a file there. For some reason it doesn't work, it always returns false. When I tried doing exactly the same thing in c# it worked fine.  Am I doing something wrong?  What if do is:  If Directory.Exists(\\DomputerName\c$\Test\) Tehn I've tr...

.net web service doesn't seem to get parameters from soap::lite
I'm using the method outlined in http://msdn.microsoft.com/en-us/library/ms995764.aspx, and also I have tried other methods on the web to call my vb.net (3.5) webservice. I can call any method that doesn't take parameters and that works fine. I can call my Authorize method which is used to authorize a credit card from a vb.net windows forms application. I can tell it isn't receiving any parameters because when I put the web service into debug, and set a break point I see all the parameters listed as nothing. This coding is really test coding I am using to verify proof of ...

Directory.Delete(path, true); doesn't work (.net 1.1) and admin can't delete
Hello all.  I have a web application that creates a user temp directory, copies files into that directory, manipulates those files, sends files to the user, and then calls Directory.Delete(path, true); to delete the temp directory and all of its contents.  The problem is that this doesn't work and the directory is still there after the method call and code execution is complete.  I also can't delete the directory manually even when logged in as an Administrator.  It says 'Cannot delete <path>: Access is denied.'.  I was under the impression that specifying 'tru...

Get Directory Size in vb.Net (doesn't return correct size in mb)
Theese code snippets don't return the correct dirsize(including subfolders and all files just like in windows) why???? 'example usage: label.text = FormatSize(GetDirectorySize(childDir.FullName)) 'methods ------------------------------------------------------------------------------------- Protected Function GetDirectorySize(ByVal thePath As String) As Long Dim dirSize As Long = 0 Dim dir As DirectoryInfo = New DirectoryInfo(thePath) ' Add the size of each file Dim theFile As FileInfo For Each theFile In dir.GetFiles() ...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'
It code worked fine on my PC..but gettting following message on server.... 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'  i checked this thread http://forums.asp.net/p/1123792/1869084.aspx#1869084  but it doesn't help me...  My Blog"Don't be afraid to be wrong; otherwise you'll never be right." Updating global assembly cache of server, solved this error Some how installation is not updating GAC..so you have to do it manuallyMy Blog"Don't be afraid to be wrong; otherwis...

Strange error: "'System.Web.UI.Controls' doesn't contain any public member..."
I get the following warnings when I Build my AJAX enabled (including web extensions) web site: Namespace or type specified in the Imports 'System.Web.UI.Controls' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. I'm not sure where to start looking - can someone point me in the right direction? I do have the following in my web.config: ... <configuration> <system.web> <pages styleSheetThem...

Web resources about - System.web.UI doesn't work in VB.Net Form? - asp.net.getting-started

Resources last updated: 1/21/2016 6:27:49 PM