473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Advice on best way to migrate to a library

I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it can
easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can put
a .aspx file into a web control library, so what would be the best way to
tackle what I need to achieve?

TIA.
Jul 10 '07 #1
9 1557
Hi,

Brian Cryer wrote:
I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it can
easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can put
a .aspx file into a web control library, so what would be the best way to
tackle what I need to achieve?

TIA.
You could "pack" the functionality in a custom class, deriving from
System.Web.UI.Page. Then, let your ASPX inherit from your custom page
instead of System.Web.UI.Page.

I use this a lot, for example to "pack" a method allowing to let an ASPX
page save itself to a static HTML "snapshot".

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 10 '07 #2
Hello Brian,

Why not to create the control for this?
or expose the interface with method with output string where your content
is rendered?

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

BCI've developed software (vb.net) that renders maps using svg. My
BCmanager would like this "mapping component" to be migrated into a
BClibrary so it can easily be used by other web based applications. So
BCfar so good.
BC>
BCHowever, the page that generates the svg (currently a .aspx file)
BCwrites directly to response. Unless I'm being silly, it doesn't look
BClike I can put a .aspx file into a web control library, so what
BCwould be the best way to tackle what I need to achieve?
BC>
BCTIA.
BC>
Jul 10 '07 #3
Consider converting it into a user control in .ascx file.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:OI**************@TK2MSFTNGP05.phx.gbl...
I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it
can easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can
put a .aspx file into a web control library, so what would be the best way
to tackle what I need to achieve?

TIA.

Jul 10 '07 #4
Ok, probably being dense, but if I create a "User Control" then all the
events I can see look appropriate for a desktop based application and not a
web-based one. If I ass a "Web Custom Control" then I can only control the
HTML that's generated - but I don't want to generate HTML but something else
(svg).

So how should I proceed, or what am I doing wrong?
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:O9**************@TK2MSFTNGP04.phx.gbl...
Consider converting it into a user control in .ascx file.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:OI**************@TK2MSFTNGP05.phx.gbl...
>I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it
can easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can
put a .aspx file into a web control library, so what would be the best
way to tackle what I need to achieve?

TIA.


Jul 10 '07 #5
"Laurent Bugnion, MVP" <ga*********@bluewin.chwrote in message
news:OV**************@TK2MSFTNGP06.phx.gbl...
Hi,

Brian Cryer wrote:
>I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it
can easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can
put a .aspx file into a web control library, so what would be the best
way to tackle what I need to achieve?

TIA.

You could "pack" the functionality in a custom class, deriving from
System.Web.UI.Page. Then, let your ASPX inherit from your custom page
instead of System.Web.UI.Page.

I use this a lot, for example to "pack" a method allowing to let an ASPX
page save itself to a static HTML "snapshot".
Thank's Laurent, this idea has great potential. Simple too.
Jul 10 '07 #6
I would create a control if I were creating something that would render in
HTML. Part of it is HTML and I do use a control for that, but the svg that
gets displayed isn't part of the webpage but is generated on the fly
separately. Its repackaging the generation of that svg that I'm
investigating. Currently on my page load I do a Response.Clear and then
write directly to Response the svg that I want to generated. I don't think a
custom web control would let me do this.

Thanks for the thought though. If I've overlooked something obvious then do
please let me know!
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:a2***************************@msnews.microsof t.com...
Hello Brian,

Why not to create the control for this?
or expose the interface with method with output string where your content
is rendered?

---
WBR, Michael Nemtsev [.NET/C# MVP]. My blog:
http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

BCI've developed software (vb.net) that renders maps using svg. My
BCmanager would like this "mapping component" to be migrated into a
BClibrary so it can easily be used by other web based applications. So
BCfar so good.
BCBCHowever, the page that generates the svg (currently a .aspx file)
BCwrites directly to response. Unless I'm being silly, it doesn't look
BClike I can put a .aspx file into a web control library, so what
BCwould be the best way to tackle what I need to achieve?
BCBCTIA.
BC>

Jul 10 '07 #7


--
John Saunders [MVP]

"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:OI**************@TK2MSFTNGP05.phx.gbl...
I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it
can easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can
put a .aspx file into a web control library, so what would be the best way
to tackle what I need to achieve?

TIA.
Jul 10 '07 #8
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:OI**************@TK2MSFTNGP05.phx.gbl...
I've developed software (vb.net) that renders maps using svg. My manager
would like this "mapping component" to be migrated into a library so it
can easily be used by other web based applications. So far so good.

However, the page that generates the svg (currently a .aspx file) writes
directly to response. Unless I'm being silly, it doesn't look like I can
put a .aspx file into a web control library, so what would be the best way
to tackle what I need to achieve?
My advice is going to be a bit different from the others.

I suggest that you abstract as far away from ASP.NET as you can, but a step
at a time.

Step 1: When you do a Response.Write(string), you're pretty much doing the
same thing as Response.Output.Write(string). Same for the other overloads of
Response.Write. So, first, try replacing one of the uses of Response.Write
with Response.Output.Write. Then Test. If it works, replace another one.
Then Test. If you get bored, you can replace all the references to
Response.Write with Response.Output.Write. Then Test. If it works, you can
go on to step 2.

Step 2: Find your lowest-level Sub or Function that calls
Response.Output.Write. By this I mean the Sub that calls
Response.Output.Write, but which does not call any other Sub or Function
that calls Response.Output.Write. Let's say that Sub is like this:

Sub LowLevelWrite(arg0 As Integer, arg1 As String)
'...
Response.Output.Write(Something)
'...
End Sub

Change it as follows:

Sub LowLevelWrite(arg0 As Integer, arg1 As String, writer As TextWriter)
'...
writer.Write(Something)
'...
End Sub

Locate the callers of LowLevelWrite (that should be easy, since they won't
build!) and add a third parameter:

' Old:
LowLevelWrite(1, "One")

' New:
LowLevelWrite(1, "One", Response.Output)

After making those changes, Test. If it works, do the same for all your
other methods that call Response.Output.Write. Do it from the innermost
outwards, and you'll eventually have only the outermost parts of your code
that reference Response.Output. Remember to Test. When it all works, go on
to step 3.

Step 3: Since this is a Web Application, your remaining references to
Response.Output will probably be in event handlers and possibly in the
markup. Find one of the event handlers that still references
Response.Output. If it's simple, then leave it alone and go on to the next
one.

When you find a handler of significant size, you'll need to turn most of it
into one or more separate Subs or Functions. This can take a while if you do
it by hand, so I can only show you the ultimate result.

' Old:
Sub btnSubmit_Click _
Handles btnSubmit.Click ' Pardon any syntax errors, it's been a while
'...
LowLevel1(intVar1, stringVar1, Response.Output)
LowLevel2(intVar2, stringVar2, Response.Output)
'...
End Sub

' New:
Sub btnSubmit_Click _
Handles btnSubmit.Click ' Pardon any syntax errors, it's been a while
'...
Separate(intVar1, intVar2, stringVar1, stringVar2, writer)
'...
End Sub

Sub Separate(intVar1 As Integer, intVar2 As Integer, stringVar1 As String,
stringVar2 As String, writer As TextWriter)
'...
LowLevel1(intVar1, stringVar1, writer)
LowLevel2(intVar2, stringVar2, writer)
'...
End Sub

This is called an "Extract Method" refactoring. Do it a little at a time,
and Test frequently.

If you do this for all the handlers that reference Response.Output, you'll
get to the point where the only code that still references Response.Output
is in your event handlers, which are pretty specific to ASP.NET web pages
anyway. You'll be in a better position to separate the code that isn't
web-page specific into separate classes (do it a little at a time, and
Test).

When you're done with all that, the part you separated out will be your
library. And, because you tested so frequently, you will not have broken
anything (or not much) in the process.

If this is important to your manager, he should spring for the $200 for a
ReSharper license. Version 3.0, recently released, now supports VB.Net. See
http://www.jetbrains.com/resharper/f...or_Enhancement.

Good luck with this. It's the sort of thing that can be fun, assuming that
you Test frequently enough to have confidence that you aren't breaking
anything.
--
John Saunders [MVP]

Jul 10 '07 #9
"John Saunders [MVP]" <john.saunders at trizetto.comwrote in message
news:OE**************@TK2MSFTNGP02.phx.gbl...
<snip>
Good luck with this. It's the sort of thing that can be fun, assuming that
you Test frequently enough to have confidence that you aren't breaking
anything.
It looks interesting (and fun). I have a couple of days before I need to
dive in and start this, so time to have a think (and sleep) on the best way
forward.

Thanks.
Jul 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dan | last post by:
Hi, I want to migrate a survey program to web application and have selected PHP to use a on the server end along with apache and firebird rdms. As developing a web application is much different...
6
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to...
2
by: Nate | last post by:
I am looking for any advice on migrating an existing VB.Net application to ASP.Net. What is the easiest method for moving the GUI forms to ASP.Net? The forms only use standard winform controls that...
5
by: Natan | last post by:
I want to create an n-tier app and I would like an advice of you that know more than me about this. I want my app to support multiple databases in the way that when a client wants to use Oracle...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
4
by: Golard | last post by:
Hello, My project is actually in VB6 (Visual Studio 6) on XP. This project is Vista compatible, and has to stay XP compatible. I'm going to install VS2008 and migrate my project: First step, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.