Simple newbie questions

  • Thread starter Thread starter Jeremy
  • Start date Start date
J

Jeremy

What is the generally accepted way to call one webform from another ? I have
found server.transfer and response.redirect but these lose the calling
window.

How do I programmatically change a page title ? Can I remove the " -
Microsoft Internet Explorer" suffix IE seems to insist on adding ?

How do I programatically get a reference to the server directory where the
aspx form resides ? eg. "C:\inetpub\wwwroot\myApp". I want to generate some
xml cache files in there, or is this not the best place to put such files ?

How can I programatically determine (from some common library code) whether
the running environment is webforms or windows client ?
 
-----Original Message-----
What is the generally accepted way to call one webform from another ? I have
found server.transfer and response.redirect but these lose the calling
window.

If you pass
Server.Transfer("YourPage.aspx", true)
the original page is preserved.

Ref:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/vbcon/html/vbtskredirectinguserstoanotherpage.asp

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconPassingServerControlValuesBetweenPages
..asp
How do I programmatically change a page title ? Can I remove the " -
Microsoft Internet Explorer" suffix IE seems to insist on
adding ?

I don't know. Why don't you just change what is in the
title tag in the aspx?
How do I programatically get a reference to the server directory where the
aspx form resides ? eg. "C:\inetpub\wwwroot\myApp". I want to generate some
xml cache files in there, or is this not the best place
to put such files ?

Server.MapPath(".");
How can I programatically determine (from some common library code) whether
the running environment is webforms or windows client ?

Don't you know what architecture you are using?
 
The simple answer is that we are developing for BOTH architectures. I want
some common library class files that are used in both environments - but in
certain cases it needs to do things slightly differently. I'd rather just
build in some simple switches rather than rewrite the whole functions for
both environments.
 
What is the generally accepted way to call one webform from another ? I
have
found server.transfer and response.redirect but these lose the calling
window.

There is none. Server.Transfer, Response.Redirect, and the other methods of
transferring from one WebForm to another all exist because each of them has
qualities that the other(s) don't. You use the technique which is best
suited to the needs of your application at the time. I have no idea what
"lose the calling window" means.
How do I programmatically change a page title ? Can I remove the " -
Microsoft Internet Explorer" suffix IE seems to insist on adding ?

The title tag is in the head portion of your page. You can make it into an
HtmlGenericControl by adding an ID and a runat=server attribute to it, and
declaring an instance of it in your CodeBehind. As to removing the "suffix"
that IE puts in there, no you can't.
How do I programatically get a reference to the server directory where the
aspx form resides ? eg. "C:\inetpub\wwwroot\myApp". I want to generate some
xml cache files in there, or is this not the best place to put such files
?

AppDomain.CurrentDomain.BaseDirectory will return the base directory of your
app.
How can I programatically determine (from some common library code) whether
the running environment is webforms or windows client ?

Check System.Web.HttpContext.Current - If it is Nothing, it is not a web
app.

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Jeremy

Why don't you just create a class library project, in which you'd put all
your common functions, and then develop your web application and windows
forms application.

In both the asp.net/winforms apps, you'd just Reference your class library
DLL (or Project) and then put:

Imports YourClassLibrary.YourCommonFunctionsClass (VB)
or using YourClassLibrary.YourCommonFunctionsClass; (C#)

at the top of every class in your codebehind files.

Seems the best way to do it.

Regards,
Anthony.
 
Back
Top