Saturday, March 31, 2012
Server Side Code dependent on JavaScript
On a Button Click, I am using JavaScript to print to current page. When the print has been sent, I want to run a Server Side Function to update a record (which also changes the screen so I have to wait until it prints to run the server side function).
Thanks.I imagine in your JS function, you could print and then do a postback to the server?
This may get your problem resolved.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Button1.Attributes.Add("onClick","javascript:DoSomething();");
string html = "";
html += "<script>";
html += " function DoSomething()";
html += " {";
html += " window.print();";
html += " }";
html += "</script>";
Response.Write(html);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Update();
}
public void Update()
{
Response.Write("Now going to update the record.");
}
How to force a postback using javascript:
http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx
Saturday, March 24, 2012
server upgraded to DC, HELP
controller (w/DNS, and DHCP) and I'm now experincing issues.
The first was no access to the ASP Framework TEMP directory, and I foudn an
article to fix that.
Now when I create a new project and add existing files to it (i.e. aspx and
.vb files) they don't work the same. Getting no class asoictaed to the .as
px
page, when there is one, also getting strange db call behavior?
Is there anything else I should know or do?
HELP'Did you try this fix for the mapping?
http://support.microsoft.com/?scid=...6351&sid=global
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
>I made my current web server (win2003 standard, with SQl Server 2K) a
>Domain
> controller (w/DNS, and DHCP) and I'm now experincing issues.
> The first was no access to the ASP Framework TEMP directory, and I foudn
> an
> article to fix that.
> Now when I create a new project and add existing files to it (i.e. aspx
> and
> .vb files) they don't work the same. Getting no class asoictaed to the
> .aspx
> page, when there is one, also getting strange db call behavior?
> Is there anything else I should know or do?
> HELP'
Hi, Chris.
for a very comprehensive view of the potential
pitfalls associated with running IIS 6.0 on a domain
controller, view the support webcast titled:
"Successfully Running IIS on a Domain Controller".
http://msevents.microsoft.com/CUI/E...e=en-U
S
It deals with account permission pitfalls, security pitfalls,
logon policies, group policies, and common problems that
can cause IIS or the domain controller to fail.
Several scenarios with different types of domain
configuration are explained and viewing this support
webcast might give you a hint as to what went wrong.
Juan T. Llibre
ASP.NET MVP
===========
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
>I made my current web server (win2003 standard, with SQl Server 2K) a
>Domain
> controller (w/DNS, and DHCP) and I'm now experincing issues.
> The first was no access to the ASP Framework TEMP directory, and I foudn
> an
> article to fix that.
> Now when I create a new project and add existing files to it (i.e. aspx
> and
> .vb files) they don't work the same. Getting no class asoictaed to the
> .aspx
> page, when there is one, also getting strange db call behavior?
> Is there anything else I should know or do?
> HELP'
thanx, mapping? but neither apply. IIS was running and installed prior, I
never removed it also. And I just promoted it to a DC. I did run one of thos
e
commands to fix the TEMP location issue as I mentioned.
Any other ideas?
"Ken Cox [Microsoft MVP]" wrote:
> Did you try this fix for the mapping?
> http://support.microsoft.com/?scid=...6351&sid=global
>
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
>
server upgraded to DC, HELP
controller (w/DNS, and DHCP) and I'm now experincing issues.
The first was no access to the ASP Framework TEMP directory, and I foudn an
article to fix that.
Now when I create a new project and add existing files to it (i.e. aspx and
..vb files) they don't work the same. Getting no class asoictaed to the .aspx
page, when there is one, also getting strange db call behavior?
Is there anything else I should know or do?
HELP??Did you try this fix for the mapping?
http://support.microsoft.com/?scid=...6351&sid=global
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
>I made my current web server (win2003 standard, with SQl Server 2K) a
>Domain
> controller (w/DNS, and DHCP) and I'm now experincing issues.
> The first was no access to the ASP Framework TEMP directory, and I foudn
> an
> article to fix that.
> Now when I create a new project and add existing files to it (i.e. aspx
> and
> .vb files) they don't work the same. Getting no class asoictaed to the
> .aspx
> page, when there is one, also getting strange db call behavior?
> Is there anything else I should know or do?
> HELP??
Hi, Chris.
for a very comprehensive view of the potential
pitfalls associated with running IIS 6.0 on a domain
controller, view the support webcast titled:
"Successfully Running IIS on a Domain Controller".
http://msevents.microsoft.com/CUI/E...5&Culture=en-US
It deals with account permission pitfalls, security pitfalls,
logon policies, group policies, and common problems that
can cause IIS or the domain controller to fail.
Several scenarios with different types of domain
configuration are explained and viewing this support
webcast might give you a hint as to what went wrong.
Juan T. Llibre
ASP.NET MVP
===========
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
>I made my current web server (win2003 standard, with SQl Server 2K) a
>Domain
> controller (w/DNS, and DHCP) and I'm now experincing issues.
> The first was no access to the ASP Framework TEMP directory, and I foudn
> an
> article to fix that.
> Now when I create a new project and add existing files to it (i.e. aspx
> and
> .vb files) they don't work the same. Getting no class asoictaed to the
> .aspx
> page, when there is one, also getting strange db call behavior?
> Is there anything else I should know or do?
> HELP??
thanx, mapping? but neither apply. IIS was running and installed prior, I
never removed it also. And I just promoted it to a DC. I did run one of those
commands to fix the TEMP location issue as I mentioned.
Any other ideas?
"Ken Cox [Microsoft MVP]" wrote:
> Did you try this fix for the mapping?
> http://support.microsoft.com/?scid=...6351&sid=global
>
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:B7E74F8A-B011-4068-BD29-E702AD88E502@.microsoft.com...
> >I made my current web server (win2003 standard, with SQl Server 2K) a
> >Domain
> > controller (w/DNS, and DHCP) and I'm now experincing issues.
> > The first was no access to the ASP Framework TEMP directory, and I foudn
> > an
> > article to fix that.
> > Now when I create a new project and add existing files to it (i.e. aspx
> > and
> > .vb files) they don't work the same. Getting no class asoictaed to the
> > .aspx
> > page, when there is one, also getting strange db call behavior?
> > Is there anything else I should know or do?
> > HELP??
>
Server, Session, Request and Response in Classes?
Perhaps a really strange question...
Is there a way that I can access the Server, Session Request and Response objects from the current page request from inside a class (not a web control) without explicitly passing them in from a web control?
My problem is that I have been developing my web application thinking that all static class members would be reset after each page request - but I've just realized that those members keep their values from request to request (and I assume across all users too?) This means I have some major restructuring to do, and the only way I can think of fixing this is to store my user-specific objects in the user session...and thus, I need access to the Session in some of my classes that accessed those static members. :S
Having a tough time wrapping my mind around the whole thing at the moment...I'm used to ASP 5.0. Maybe there's a better way to go about this altogether.
to access those items from a non-page class, you can use:
HttpContext.Current
this will give you access to
HttpContext.Current.Session
HttpContext.Current.Request
etc...
The class member properties/values wont be passed unless you are rebinding them, saving them in session/application or some other way passing them. It's more then likely a matter of how you are populating them that's causing you frustration.
Show the specific code you are using and what you think is the cause of the problem... we'll see what we can do to help out.
I think I know what you mean. Offloading stuff blindly into the user session is not a good idea. I have a lot of restructuring to do...
Speaking of which, there doesn't happen to be a convenient way to get the current instance of the System.Web.UI.Page object from within any class, is there? I couldn't find anything relevant to this in the HttpContext, and I don't know where else to look.
Thanks!!
you shoudnt need it in your class (the business layer should be UI independent).... if, for some reason you do though you'll have to pass in the instance of it.
Draggor:
there doesn't happen to be a convenient way to get the current instance of the System.Web.UI.Page object from within any class, is there?
You can get at the current page instance from HttpContext like this:
Dim currentPageAs Page =DirectCast(HttpContext.Current.Handler, Page)
Tuesday, March 13, 2012
Server.MapPath
I was using Server.MapPath to check if a file existed in the current domain and then display it so it would be displayed inwww.domainA.com/Pictures/PictureName.jpg
but now I want to check if the file exists on the same server, but in a different folder, which would be a different domain. I tried using an absolute url for the path but that didn't work. How would you do this?
Here's what I have now. Thanks
// Display the product's image if it has one
if (System.IO.File.Exists(Server.MapPath("Pictures/" + ProductLabel.Text +".jpg")) !=false){
ProductImage.ImageUrl = ("Pictures/" + ProductLabel.Text +".jpg");
}
this line of code will give u return true/false
based upon the directory exits on the server.
If Directory.Exists(NewPath)
Do you want to load an image which is not in your web site directory hierarchy?
Hi rkeslar,
Generally speaking, server.mappath is designed to return the physical path for those virtue paths which areUNDER your current domain.So-- if the virture path you want to check is outside your current domain( in another project), i'm afraid you cannot use it( Imagine how are you going to write the virtue path part??)
If you do want to check if a certain folder/file exist or not , simply using System.IO.File.Exists(physicalpath) will do it.But i'm assuming you have already known the physical path.
Hope my suggestion helps
server.mappath
frm1.1 c#
in my project library(.cs) when i use server.mappath() it never works why?
i useHttpContext.Current.Server.MapPath();
to access but it never reads the path of the file give why?
Are you sure your project library has access to the HttpContext? In other words, when you are debugging, is HttpContext.Current null?
What do you mean by it never works!! make sure you import the System.Web namespace using System.Web;
HC
thanks everybody for the reply
haissam i have used system.web namespace
i dont know why the server.mappath never gets the file path when in mylibrary project files
Are you working on a web application ?