Monday, March 26, 2012
Please Help
it will generate a text file into a excel file before that i need to a
program which able to load the text file into database sql. Can any one
possiable helping me solving this problem?Can you please describe your problem with more detail?
please help
Dim objWord As New Word.Application
Dim docNew As New Word.Document
and i am using the following code to close and quit the applications:
'Close the Automation object
objWord.Quit()
' Cleanup the unmanaged objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(objWord)
but when i look at the processes in my task manager winword.exe with username asp.net never ends, and the more i run the application, the more winword.exe's that open. Am i trying to close it wrong?
thanks in advance for any help!I'm not familiar with using word with ASP.NET, but after you release the object you should set it = nothing. This marks the object for garbage collection and allows the object to be destroyed.
You need to do:
docNew.Close(Word.wdSaveOptions.wdDoNotSaveChanges)
Marshal.ReleaseComObject(docNew)
docNew = nothing
objWord.Quit(Word.wdSaveOptions.wdDoNotSaveChanges)
Marshal.ReleaseComObject(objWord)
objWord = nothing
Brian
Thanks a million, that works perfectly! thanks for your help!
Please Help - How to do Content Gathering!
I need to be pointed in some direction on how this can be done using C#.
Lets say that there is a link for a tab delimited .txt file, or a excel spreedsheet with information that i want to get from one site and populate my database off of that information. But i want to be able to make my webapp smart enough to be able to go get this information in some kind of intervals I want (i.e. --> weekly, monthly, every 3 months...)
Can someone please point me in the right direction as to where I can find how to do this...
thanks in advance.If this has to happen on a regular basis - thus not request-based - ASP.NET is likely not the platform to use. Well, it's the platform to use when creating the web app, but not the technology to gather the content. Instead, there are quite some ways to do this:
1. Create a Windows application to gather content and schedule it using at.exe or the Windows Scheduling in the Control Panel.
2. Create a background Windows Service that can do the gathering behind the scenes.
3. (Advanced) Create a SQL Server Notification Services app that accepts incoming inputs from various sources and - as a delivery - inserts the new retrieved data in the database.
Aye create a service to query your remote server every (X) [x = your interval].
Then have it bring your stream back and parse through it. What are you writing this in c# or vb. You do know depending on what your doing with spreadsheets you may need a copy of excel on your server?
I got a little code that basically works. my problem is that the site i am gathering the information from has sessions on it. so if i just put in the link to the site's file i'll will tell me that the session has expired or that there was a problem with the page. Here is the code I have.
and yes, excel and all the goodies are on the server already.
private void Page_Load(object sender, System.EventArgs e)
{
// it works when the open read command is pointed to the actual file.
System.Net.WebClient Client = new WebClient();
Stream strm = Client.OpenRead("http://www.whatever.com");
StreamReader sr = new StreamReader(strm);string line;
if (strm != null)
{
do
{
line = sr.ReadLine();
ListBox1.Items.Add(line);
}
while (line !=null);
strm.Close();
}
else
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = "Something went wrong";
}Stream strm2 = Client.OpenRead("http://www.whatever.com.aspx?format=excel&prefix=");
StreamReader sr2 = new StreamReader(strm2);
line = string.Empty;if (strm2 != null)
{
do
{
line = sr2.ReadLine();
ListBox2.Items.Add(line);
lblStatus.Text = line;
}
while (line !=null);
strm2.Close();
}
else
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = "Something went wrong";
}}
Saturday, March 24, 2012
please help .. with Microsoft webcontrols ..
csc.exe is valid. see below example.
c:\windows\microsoft.net\framework\v1.1.4322\csc.exe
Also run build.bat from the DOS shell not the Run menu so you can see what is happening.
I downloaded the IE Web controls package
For the love of our lord Jesus Christ, why?
and as instructed ran the Build file which does create the build folder with a subfolder called runtime but I do not see any Microsoft.Web.UI.WebControls.dll being created anywhere in this folder. What is going on ?
Are you building through commandline, and when building, did you resolve the first 'error'? (THis might be entirely based on experience, but there is usually one error to resolve when you try to build it the first time
hey what do you have against the iewebcontrols... the tabstrip + multipage works ok. Do you know of any other tabbing control that's free that's better. It would make my life a lot easier.
Free? No.
Better? All of them.
The IE Web Controls are the equivalent of Windows Millennium. It works, but it really isn't that good. If I had been a little more dishonest, I could have given you my version of the same controls I wrote for my previous company... those controls are probably on sale somewhere right now. :(
Please help explain what an "application instance" really is in terms of static data
static data there and in another module used in the asp.net application and
I realize that static data is shared amongst child apps of an IIS
application and can be used by multiple users during the application life
cycle and for multiple page loads for the same or different page under a
root application.
What I don't understand and need to know is whether that static data would
be shared by ALL users of my application on a single server if my
application was loaded at all or whether it is possible to have my
application loaded multiple times such that each loading of my application
has its own set of static data that is potentially shared by multiple users.
Exactly what is an asp.net "application instance" in terms of windows
process, thread and object terminology which I understand well - is it a
user's sequenced use of the loaded assembly, concurrent thread usage of an
assembly or is it multiple loads of an assembly each of which can be used by
multiple users/threads?
As an analogy, let's say I write a multi threaded desktop app and allowed
multiple threads to use an object called X that was created by the main
thread. If that object X had static data then all threads in one process
that loaded my application would share that data in X even if each thread
had its own instance of X. But if I loaded 2 copies of my desktop
application (like running 2 copies of notepad.exe), each process would have
only one instance of object X static data no matter how many isntances of X
and each set of X static data would be shared by multiple threads in that
process but the staic data would not be shared between processes.
My concern is what scope I must lock at for all users of my asp.net
application on one machine. Can there be multiple copies of my static data?
One for each asp.net "application instance" or whether instance is just
referring to the fact that multiple users can be sharing the same static
data in the module that was loaded for the benefit of multiple users which I
believe I read are sequenced thru one at a time. Or do I really have to
worry about some users sharing one set of static data for one loading of my
application and another set of users sharing another set of static data
because my asp.net application was loaded again for them?
Hope I made myself clear. If I can have multiple sets of users each with
their own shared static data then I need to somehow lock across the multiple
copies of the static data.
So to summarize:
1. Can/must a C# lock be used for static data for ALL users on one machine -
depends if users are sequenced thru the application. Or is this totally
insufficient to protect a shared resource under asp.net?
2. Or rather must I somehow externally [like named semaphores] synchronize
across multiple application instances to protect that truly only one user at
a time on a given machine can modify a resource similar to what I would need
to do if I had multiple desktop processes running on one machine that had to
sequence use of a resource one at a time?
Whew...thanks!
Dave"static" means there is only one copy of the data. This is available to all
users of an application. If one user changes it, it is changed for all users.
You need to study the difference between the ASP.NET Application object vs.
what is "static" - they have similar features but are not the same thing. An
Application is a running instance of your web site in IIS, to put it in
simplest terms.
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Dave" wrote:
Quote:
Originally Posted by
I have a global.asax file with Application_Start defined and create some
static data there and in another module used in the asp.net application and
I realize that static data is shared amongst child apps of an IIS
application and can be used by multiple users during the application life
cycle and for multiple page loads for the same or different page under a
root application.
>
What I don't understand and need to know is whether that static data would
be shared by ALL users of my application on a single server if my
application was loaded at all or whether it is possible to have my
application loaded multiple times such that each loading of my application
has its own set of static data that is potentially shared by multiple users.
>
Exactly what is an asp.net "application instance" in terms of windows
process, thread and object terminology which I understand well - is it a
user's sequenced use of the loaded assembly, concurrent thread usage of an
assembly or is it multiple loads of an assembly each of which can be used by
multiple users/threads?
>
As an analogy, let's say I write a multi threaded desktop app and allowed
multiple threads to use an object called X that was created by the main
thread. If that object X had static data then all threads in one process
that loaded my application would share that data in X even if each thread
had its own instance of X. But if I loaded 2 copies of my desktop
application (like running 2 copies of notepad.exe), each process would have
only one instance of object X static data no matter how many isntances of X
and each set of X static data would be shared by multiple threads in that
process but the staic data would not be shared between processes.
>
My concern is what scope I must lock at for all users of my asp.net
application on one machine. Can there be multiple copies of my static data?
One for each asp.net "application instance" or whether instance is just
referring to the fact that multiple users can be sharing the same static
data in the module that was loaded for the benefit of multiple users which I
believe I read are sequenced thru one at a time. Or do I really have to
worry about some users sharing one set of static data for one loading of my
application and another set of users sharing another set of static data
because my asp.net application was loaded again for them?
>
Hope I made myself clear. If I can have multiple sets of users each with
their own shared static data then I need to somehow lock across the multiple
copies of the static data.
>
So to summarize:
>
1. Can/must a C# lock be used for static data for ALL users on one machine -
depends if users are sequenced thru the application. Or is this totally
insufficient to protect a shared resource under asp.net?
>
>
2. Or rather must I somehow externally [like named semaphores] synchronize
across multiple application instances to protect that truly only one user at
a time on a given machine can modify a resource similar to what I would need
to do if I had multiple desktop processes running on one machine that had to
sequence use of a resource one at a time?
>
Whew...thanks!
>
Dave
>
>
static data is visible to all threads in the same ApplicationDomain. the
appdomain represents an instance of the clr vm. each app domain has its
own memory, stack, code and heap (gc).
an actually program can host more have more than one appdomain, and
appdomain can talk to each other, but only thru remoting (even if in the
same nt process).
with asp.net there is a worker process per application pool. you can
config asp.net to use one pool (process) or more.
when an asp.net application is defined in IIS (its bound to a vdir), you
assign it to the pool. when the asp.net application (i'll call website
because there are too many application references) is started, an
appdomain is created and its loaded into it. normally there is only one
appdomain per website. so statics are shared between all users (threads)
of that website.
but when a website recycle happens (code changed, too much memory,etc),
a new appdomain is started, and the old one is shut down. if there any
request using the old appdomain, they complete while new requests use
the new appdomain. they do not see each others statics.
this last issue becomes important if you are referencing a unmanaged
dll. the unmanaged dll is actually loaded into the worker process, so
any statics in it are shared across both appdomains and in fact all
other websites using the same pool.
just to confuse things a little, there is a Application object, which
global.asx represents. the instances of these are maintained in a pool,
as each request gets its on unique instance. (this is for performace
reasons beyond the scope of this over simplified explanation). this is
why there is are begin and end events, hooking to create/dispose would
happen too often.
your application statics may or may not need locking. application begin
fires and completes before any other request has access to the
application. so read only can safely be loaded during this event without
locks. if it a read/write resource and does not sync access on its own,
then you need to use locks. c# has a lock statement you can use.
this is different than session, which has serialized access, as only one
request is processed at a time that uses the same session. this allows
concurrent request, just not to the same session data. this would be too
limiting for application access, so you need locks.
note: the application cache has serialized access to the object, but
does not sync methods/property accesses. the object should be thread
safe, or again you need to use locks.
-- bruce (sqlwork.com)
Dave wrote:
Quote:
Originally Posted by
I have a global.asax file with Application_Start defined and create some
static data there and in another module used in the asp.net application
and I realize that static data is shared amongst child apps of an IIS
application and can be used by multiple users during the application
life cycle and for multiple page loads for the same or different page
under a root application.
>
What I don't understand and need to know is whether that static data
would be shared by ALL users of my application on a single server if my
application was loaded at all or whether it is possible to have my
application loaded multiple times such that each loading of my
application has its own set of static data that is potentially shared by
multiple users.
>
Exactly what is an asp.net "application instance" in terms of windows
process, thread and object terminology which I understand well - is it a
user's sequenced use of the loaded assembly, concurrent thread usage of
an assembly or is it multiple loads of an assembly each of which can be
used by multiple users/threads?
>
As an analogy, let's say I write a multi threaded desktop app and
allowed multiple threads to use an object called X that was created by
the main thread. If that object X had static data then all threads in
one process that loaded my application would share that data in X even
if each thread had its own instance of X. But if I loaded 2 copies of my
desktop application (like running 2 copies of notepad.exe), each process
would have only one instance of object X static data no matter how many
isntances of X and each set of X static data would be shared by multiple
threads in that process but the staic data would not be shared between
processes.
>
My concern is what scope I must lock at for all users of my asp.net
application on one machine. Can there be multiple copies of my static
data? One for each asp.net "application instance" or whether instance is
just referring to the fact that multiple users can be sharing the same
static data in the module that was loaded for the benefit of multiple
users which I believe I read are sequenced thru one at a time. Or do I
really have to worry about some users sharing one set of static data for
one loading of my application and another set of users sharing another
set of static data because my asp.net application was loaded again for
them?
>
Hope I made myself clear. If I can have multiple sets of users each with
their own shared static data then I need to somehow lock across the
multiple copies of the static data.
>
So to summarize:
>
1. Can/must a C# lock be used for static data for ALL users on one
machine - depends if users are sequenced thru the application. Or is
this totally insufficient to protect a shared resource under asp.net?
>
>
2. Or rather must I somehow externally [like named semaphores]
synchronize across multiple application instances to protect that truly
only one user at a time on a given machine can modify a resource similar
to what I would need to do if I had multiple desktop processes running
on one machine that had to sequence use of a resource one at a time?
>
Whew...thanks!
>
Dave
>
Thanks so much Bruce. This clears up several issues understanding more what
happens. I forgot since this is managed code that the framework can do
things within a windows process that unmanaged code cannot such as
isolation. If you could bear with me I need clarification on a few points:
1. Sounds like in the normal case, ALL users of a website application shares
static data since there the code is loaded into only one appdomain. But
there could be 2 or more appdomains running the code in the case of recycle,
configuring multiple pools or I'm guessing in the case of a web garden in
which case there would be multiple instances of my static data loaded with
some users assigned to one and others to another. Did I understand that
right?
2. I understand the unmanaged dll situation and is not a concern for me.
3. I'm confused on your description of the Application object as to each
user getting their own instance. I thought that object was shared by all
users of the application even if there could possibly be multiple appdomains
running that application as in the cases you mentioned. 'Course they do say
"Application Instance" which I think is at the root of my confusion. What is
meant by "instance" in this case?
4. If Application_Start runs when the application is loaded for the first
user, does it not have to finish before any other user enters the code? If
so then why would it matter if any sort of locking ws used or not for
readonly or readwrite resoruces? I probably misunderstood. Am unclear if
asp.net code has to be rentrant as I read once that users are serialized
thru an application but have my doubts as that would not scale very well.
5. Am also thinking that using "lock (static myobject)" would only work
within a single appdomain and that if in fact multiple appdomains had my
code loaded it would not serialize access amongst appdomains but only for
threads within an appdomain if for no other reason than that they had their
own copy of "myobject". Did you mean to say that somehow the C# lock would
work between appdomains or did I misunderstand?
6. Given, let's say, the possibility of multiple appdomains running the same
code wanting to update a file shared by all the child applications in an IIS
application, what would you recommend for synchronization so they don't step
on each other? A named semaphore or named mutex?
Thanks again,
Dave
"bruce barker" <nospam@.nospam.comwrote in message
news:OBMF2aAKIHA.4592@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
static data is visible to all threads in the same ApplicationDomain. the
appdomain represents an instance of the clr vm. each app domain has its
own memory, stack, code and heap (gc).
>
an actually program can host more have more than one appdomain, and
appdomain can talk to each other, but only thru remoting (even if in the
same nt process).
>
with asp.net there is a worker process per application pool. you can
config asp.net to use one pool (process) or more.
>
when an asp.net application is defined in IIS (its bound to a vdir), you
assign it to the pool. when the asp.net application (i'll call website
because there are too many application references) is started, an
appdomain is created and its loaded into it. normally there is only one
appdomain per website. so statics are shared between all users (threads)
of that website.
>
but when a website recycle happens (code changed, too much memory,etc), a
new appdomain is started, and the old one is shut down. if there any
request using the old appdomain, they complete while new requests use the
new appdomain. they do not see each others statics.
>
this last issue becomes important if you are referencing a unmanaged dll.
the unmanaged dll is actually loaded into the worker process, so any
statics in it are shared across both appdomains and in fact all other
websites using the same pool.
>
just to confuse things a little, there is a Application object, which
global.asx represents. the instances of these are maintained in a pool, as
each request gets its on unique instance. (this is for performace reasons
beyond the scope of this over simplified explanation). this is why there
is are begin and end events, hooking to create/dispose would happen too
often.
>
your application statics may or may not need locking. application begin
fires and completes before any other request has access to the
application. so read only can safely be loaded during this event without
locks. if it a read/write resource and does not sync access on its own,
then you need to use locks. c# has a lock statement you can use.
>
>
this is different than session, which has serialized access, as only one
request is processed at a time that uses the same session. this allows
concurrent request, just not to the same session data. this would be too
limiting for application access, so you need locks.
>
note: the application cache has serialized access to the object, but does
not sync methods/property accesses. the object should be thread safe, or
again you need to use locks.
>
>
-- bruce (sqlwork.com)
>
>
Dave wrote:
Quote:
Originally Posted by
>I have a global.asax file with Application_Start defined and create some
>static data there and in another module used in the asp.net application
>and I realize that static data is shared amongst child apps of an IIS
>application and can be used by multiple users during the application life
>cycle and for multiple page loads for the same or different page under a
>root application.
>>
>What I don't understand and need to know is whether that static data
>would be shared by ALL users of my application on a single server if my
>application was loaded at all or whether it is possible to have my
>application loaded multiple times such that each loading of my
>application has its own set of static data that is potentially shared by
>multiple users.
>>
>Exactly what is an asp.net "application instance" in terms of windows
>process, thread and object terminology which I understand well - is it a
>user's sequenced use of the loaded assembly, concurrent thread usage of
>an assembly or is it multiple loads of an assembly each of which can be
>used by multiple users/threads?
>>
>As an analogy, let's say I write a multi threaded desktop app and allowed
>multiple threads to use an object called X that was created by the main
>thread. If that object X had static data then all threads in one process
>that loaded my application would share that data in X even if each thread
>had its own instance of X. But if I loaded 2 copies of my desktop
>application (like running 2 copies of notepad.exe), each process would
>have only one instance of object X static data no matter how many
>isntances of X and each set of X static data would be shared by multiple
>threads in that process but the staic data would not be shared between
>processes.
>>
>My concern is what scope I must lock at for all users of my asp.net
>application on one machine. Can there be multiple copies of my static
>data? One for each asp.net "application instance" or whether instance is
>just referring to the fact that multiple users can be sharing the same
>static data in the module that was loaded for the benefit of multiple
>users which I believe I read are sequenced thru one at a time. Or do I
>really have to worry about some users sharing one set of static data for
>one loading of my application and another set of users sharing another
>set of static data because my asp.net application was loaded again for
>them?
>>
>Hope I made myself clear. If I can have multiple sets of users each with
>their own shared static data then I need to somehow lock across the
>multiple copies of the static data.
>>
>So to summarize:
>>
>1. Can/must a C# lock be used for static data for ALL users on one
>machine - depends if users are sequenced thru the application. Or is this
>totally insufficient to protect a shared resource under asp.net?
>>
>>
>2. Or rather must I somehow externally [like named semaphores]
>synchronize across multiple application instances to protect that truly
>only one user at a time on a given machine can modify a resource similar
>to what I would need to do if I had multiple desktop processes running on
>one machine that had to sequence use of a resource one at a time?
>>
>Whew...thanks!
>>
>Dave
>>
Bruce, would dearly love to hear your view on my response to this message.
This one was so helpful. THe doc is not very clear on these sort of issues
or on reentrancy either. Thanks, Dave
"bruce barker" <nospam@.nospam.comwrote in message
news:OBMF2aAKIHA.4592@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
static data is visible to all threads in the same ApplicationDomain. the
appdomain represents an instance of the clr vm. each app domain has its
own memory, stack, code and heap (gc).
>
an actually program can host more have more than one appdomain, and
appdomain can talk to each other, but only thru remoting (even if in the
same nt process).
>
with asp.net there is a worker process per application pool. you can
config asp.net to use one pool (process) or more.
>
when an asp.net application is defined in IIS (its bound to a vdir), you
assign it to the pool. when the asp.net application (i'll call website
because there are too many application references) is started, an
appdomain is created and its loaded into it. normally there is only one
appdomain per website. so statics are shared between all users (threads)
of that website.
>
but when a website recycle happens (code changed, too much memory,etc), a
new appdomain is started, and the old one is shut down. if there any
request using the old appdomain, they complete while new requests use the
new appdomain. they do not see each others statics.
>
this last issue becomes important if you are referencing a unmanaged dll.
the unmanaged dll is actually loaded into the worker process, so any
statics in it are shared across both appdomains and in fact all other
websites using the same pool.
>
just to confuse things a little, there is a Application object, which
global.asx represents. the instances of these are maintained in a pool, as
each request gets its on unique instance. (this is for performace reasons
beyond the scope of this over simplified explanation). this is why there
is are begin and end events, hooking to create/dispose would happen too
often.
>
your application statics may or may not need locking. application begin
fires and completes before any other request has access to the
application. so read only can safely be loaded during this event without
locks. if it a read/write resource and does not sync access on its own,
then you need to use locks. c# has a lock statement you can use.
>
>
this is different than session, which has serialized access, as only one
request is processed at a time that uses the same session. this allows
concurrent request, just not to the same session data. this would be too
limiting for application access, so you need locks.
>
note: the application cache has serialized access to the object, but does
not sync methods/property accesses. the object should be thread safe, or
again you need to use locks.
>
>
-- bruce (sqlwork.com)
>
>
Dave wrote:
Quote:
Originally Posted by
>I have a global.asax file with Application_Start defined and create some
>static data there and in another module used in the asp.net application
>and I realize that static data is shared amongst child apps of an IIS
>application and can be used by multiple users during the application life
>cycle and for multiple page loads for the same or different page under a
>root application.
>>
>What I don't understand and need to know is whether that static data
>would be shared by ALL users of my application on a single server if my
>application was loaded at all or whether it is possible to have my
>application loaded multiple times such that each loading of my
>application has its own set of static data that is potentially shared by
>multiple users.
>>
>Exactly what is an asp.net "application instance" in terms of windows
>process, thread and object terminology which I understand well - is it a
>user's sequenced use of the loaded assembly, concurrent thread usage of
>an assembly or is it multiple loads of an assembly each of which can be
>used by multiple users/threads?
>>
>As an analogy, let's say I write a multi threaded desktop app and allowed
>multiple threads to use an object called X that was created by the main
>thread. If that object X had static data then all threads in one process
>that loaded my application would share that data in X even if each thread
>had its own instance of X. But if I loaded 2 copies of my desktop
>application (like running 2 copies of notepad.exe), each process would
>have only one instance of object X static data no matter how many
>isntances of X and each set of X static data would be shared by multiple
>threads in that process but the staic data would not be shared between
>processes.
>>
>My concern is what scope I must lock at for all users of my asp.net
>application on one machine. Can there be multiple copies of my static
>data? One for each asp.net "application instance" or whether instance is
>just referring to the fact that multiple users can be sharing the same
>static data in the module that was loaded for the benefit of multiple
>users which I believe I read are sequenced thru one at a time. Or do I
>really have to worry about some users sharing one set of static data for
>one loading of my application and another set of users sharing another
>set of static data because my asp.net application was loaded again for
>them?
>>
>Hope I made myself clear. If I can have multiple sets of users each with
>their own shared static data then I need to somehow lock across the
>multiple copies of the static data.
>>
>So to summarize:
>>
>1. Can/must a C# lock be used for static data for ALL users on one
>machine - depends if users are sequenced thru the application. Or is this
>totally insufficient to protect a shared resource under asp.net?
>>
>>
>2. Or rather must I somehow externally [like named semaphores]
>synchronize across multiple application instances to protect that truly
>only one user at a time on a given machine can modify a resource similar
>to what I would need to do if I had multiple desktop processes running on
>one machine that had to sequence use of a resource one at a time?
>>
>Whew...thanks!
>>
>Dave
>>
Please Help how do I Microsoft.XMLHTTP in .net
set xml1 = CreateObject("Microsoft.XMLHTTP")
xml1.Open "GET", strURL, False
xml1.send
strXmlContents = xml1.responseText
how do I do this in .aspx?with the HTTPWebRequest class. here :
http://rtfm.atrax.co.uk/infinitemonkeys/articles/asp.net/990h.asp
That looks really nice for an advanced programer but I am completly lost. Is that in c#?
<%@. import namespace="System.Net" %>
WebClient objClient = new WebClient();
private void Page_Load(Object o, EventArgs e){
WebClient objClient = new WebClient();
}
private void Page_Load(Object o, EventArgs e){
WebClient objClient = new WebClient();
Stream objStream = objClient.OpenRead("http://lycosa/default.asp");
}
Is this all I need? what do I save this as?
> Is this all I need?
not quite. this is the code you need, sure, but you need to fill in a few bits round it. I take it you're a raw novice then?
I think I got thst part
<%@. import namespace="System.IO" %>
<%@. Control Language="vb" debug="true" Codebehind="Live Lines.ascx.vb" %>
<HTML>
<HEAD>
<title>Messing around with ASP.NET in VB</title>
</HEAD>
<body>
<script language="VB" runat="server"
Public Sub Page_Load()
Dim fileName as String
fileName = "C:\schedule.txt"
Dim strmR as StreamReader = File.OpenText(fileName)
lblStart.Text = Server.HtmlEncode(strmR.ReadToEnd()).Replace(vbcrlf, "<br />")
strmR.Close()
End Sub
</script>
<asp:label runat="server" id="lblStart" font-name="verdana" />
</body>
</HTML
This seems to work for me. 2 questions
1. How can I change this fileName = "C:\schedule.txt" for non local files? Like this, fileName = "http://blah/schedule.txt" ?
2. My information is now displayed like this
1| 1|20030915|18:05|DALLAS |219| 37|
1| 1|20030915|18:05|NY GIANTS |220| 7|
How do I convert this to xml and display it if I know the name for each category?
Yes I am a super nooob
Anyone have a suggestion?
You're going to need to split the delimited file first at the linebreaks, then at the pipe characters (|), then you'll be able to loop through the resulting arrays and stick them in an XML document.
I'll scout around and see if there's a tutorial on it somewhere, but equally there may be a library for this task on this very site...
Wednesday, March 21, 2012
Please help me
My codebehind file (.aspx.cs) will not load. When I post my web application everything works except the actual code in the .cs file. I mean that when tou press the button it will not execute the code.
If anyone can help me, please do!
Thanks!
the button have runat=server?Hello,
Is the page being refreshed (postback)?
If yes then go to your code and double click on the button to create the event handler again, then recompile.
If not then tell me to help you sorting that out.
regards
fastlearner wrote:
My codebehind file (.aspx.cs) will not load. When I post my web application everything works except the actual code in the .cs file. I mean that when tou press the button it will not execute the code.
If anyone can help me, please do!
Thanks!
Have you fully compiled your project and deployed the bin directory to your web server?
The page is not beeing refreshed!
The .cs file is probably not beeing loaded at all by the compiler, or second .dll doesn't inherit from the first.
Thanks.
Hello,
1) Try to run your application in different browser (FireFox)
2) execute this C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -c
regards
Thanks for all your help.
It seems my problem was an improper configuration of the IIS to use ASP.net
Regards
What was the problem? and what you did to solve it?
regards
Please help me ..(:
When user clicks on the PRINT button, i like the system automatically print a WEBFORM ASPX file (which is in Report format)..ie, OnClick it should call that ASPX file and print it...
Please advice me (:You have to make a "Printer Friendly Version" button that the user can click to go to that page (or load a pop up) and then call window.print(); (I think).
You can also create a style in your stylesheet that will resize the controls differently for "print" and "screen" situations. This will allow you to auto-resize all pages so they
are printer-friendly.
Hello -
I'm assuming you have something like an array (list) of documents that
you would like to choose from to print...
I had the same type of task...
I completed it with having a button for each entry on the form, and when
the user pressed a button, a child window (popup) would display the
form (or PDF)
The popup window had a header frame that allowed the user to print or
cancel the form...
the trick was, once the popup window ready to be displayed, i would create
a DIV tag around the entire contents, and the print button would print the
contents of the DIV tag...
I also added a little model window magic - to keep the child window
open until the user closes the popup.
Worked like a champ.
best of luck
take care
tony
Hi,
it's a much cleaner solution to use css for this one. Take a look at this article:CSS Design: Going to Print.
Grz, Kris.
please help me find a solution
If i should download a control some where else, where is it and just want to make sure I don't want to use database or xml file to display the treeview, I hope to be looping through the file structure directly under ,say,c:\sampleimages\image_1974\
thanksThere isn't a built-in TreeView control in ASP.NET 1.1.
There will be in 2.0.
There are existing 3rd party TreeView controls you can use.
Try looking on www.asp.net for assorted ASP.NET controls.
please help me find a solution
If i should download a control some where else, where is it and just want to make sure I don't want to use database or xml file to display the treeview, I hope to be looping through the file structure under my say,c:\sampleimages\image_1974\
thanksYou should use ASP.NET if your web server is IIS and you are willing to learn the technology that is central to Microsoft's development plans since 2002.
ASP.NET has been extended by numerous third parties for almost anything you can think of in the user interface. There are a number of perfected treeview webcontrols along with so many more items that are either new to you or much better than the controls built into ASP.NET. Microsoft's controls are there to get you started. They have built ASP.NET to be highly extendable and for it to be very easy to integrate a third party control or code.
You can find the third party products on this site's Control Gallery, www.123asp.com, and www.411asp.net.
Friday, March 16, 2012
Please Help me understand how this works......
Hi. I have this code below and wondering what file I need to import to get the pageContentsCell.Controls.Add(control) line to work.
Private Sub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.Load,Me.Load' Save DepartmentID from the query string to a variableDim departmentIdAs String = Request.QueryString("departmentID")' Save the search string from the query string to a variableDim searchStringAs String = Request.QueryString("Search")' We need to find out if the ViewCart parameter has been suppliedDim viewCartAs String = Request.QueryString("ViewCart")' Load page contentsIf Not viewCartIs Nothing Then' we display the shopping cartDim controlAs Control control = Page.LoadControl("UserControls/ShoppingCart.ascx") pageContentsCell.Controls.Add(control)ElseIf Not searchStringIs Nothing Then' you're searching the catalogDim controlAs Controlcontrol = Page.LoadControl("UserControls/SearchResults.ascx") pageContentsCell.Controls.Add(control)ElseIf Not departmentIdIs Nothing Then' you're visiting a department or categoryDim controlAs Controlcontrol = Page.LoadControl("UserControls/Catalog.ascx") pageContentsCell.Controls.Add(control)Else' you're on the main pageDim controlAs Controlcontrol = Page.LoadControl("UserControls/FirstPage.ascx") pageContentsCell.Controls.Add(control)End If End Sub Private Sub viewCartButton_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles viewCartButton.Click' Get the query string as a NameValueCollection objectIf Request.QueryString("ViewCart")Is Nothing Then Response.Redirect("default.aspx?ViewCart=1&" & _ Request.QueryString.ToString())End If End SubWhat's the error message you got for the linepageContentsCell.Controls.Add(control)? You may take a look atCreating Custom Web Controls with ASP.NET 2.0
Please help me with this connection to the database problem!
I am very new to the ASP.NET, lately I have been practicing about accessing data through Access 2002 file with ASP.NET. At the beginning, it really gave me a headache. here is my problem:
My goal is going to store User's Username, password and repassword into a db file called userDB.mdb
the project has two .aspx files as WebForm1 and 2
--------------------------------
//here is the code for the WebForm1:
(i will only provide those code-behind code, just make the message clear, if anyone needs the html code, please let me know)
--------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace uncos
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label t_Username;
protected System.Web.UI.WebControls.Label t_Password;
protected System.Web.UI.WebControls.Label t_Repassword;
protected System.Web.UI.WebControls.TextBox tb_Username;
protected System.Web.UI.WebControls.TextBox tb_Password;
protected System.Web.UI.WebControls.TextBox tb_Repassword;
protected System.Web.UI.WebControls.RequiredFieldValidator val_Username;
protected System.Web.UI.WebControls.RequiredFieldValidator val_Password;
protected System.Web.UI.WebControls.CompareValidator val_Repassword;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
if (tb_Password.Text == tb_Repassword.Text)
{
Response.Redirect(@dotnet.itags.org."WebForm2.aspx");
}
}
}
}
============================================================
//here is the code for the WebForm2:
============================================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data.OleDb;
using System.Collections.Specialized;
namespace uncos
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e)
{
NameValueCollection dataColl;
dataColl = Request.Form;
string tbUsername = dataColl["tb_UserName"];
string tbPassword = dataColl["tb_Password"];
string tbRepassword = dataColl["tb_Repassword"];
OleDbConnection cnn = new OleDbConnection(@dotnet.itags.org."Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\userDB.mdb");
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "INSERT INTO User_Table(User_ID,Password,Repassword) VALUES('"+tbUsername+"','"+tbPassword+"','"+tbRepassword+"')";
cmd.Connection = cnn;
cmd.CommandType = CommandType.Text;
try
{
cnn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text=ex.ToString();
}
finally
{
if(cnn.State == ConnectionState.Open)
{
cnn.Close();
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
============================================================
//It has runtime error.
//the error message is:
============================================================
System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'c:\userDB.mdb'. It is already opened exclusively by another user, or you need permission to view its data. at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at uncos.WebForm2.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\uncos\webform2.aspx.cs:line 40
============================================================
I have been doing lots of reserch to solve this problem, but none of them work.
I don't have the problems of file or folder sharing, all the accounts on my PC has the full control to that .mdb file.
.mdb file is not in the Inetpub folder as well, I put it under C:\, just in case the security permission problem occurs.
All the programs who can access that .mdb file are closed before I test the page.
I can't find anything else could cause the problem.
Please help me!!! Cheers!!!!
LeeMake sure that your account that runs ASP.NET applications has sufficient security privledges to the directory that the Access database is in.
Thanks for your advise, I am using the Administrater Account on my PC (it's XP), I have give this account full control of the C driver. But nothing changes.
Lee
No, the asp.net worker process uses an account (probably a user named ASP.NET on XP).. give this user permission to the directory, not the user you are logged in with.
Thanks again!!!
I have got four accounts on my PC.
they are :
MyName(Computer Adminstrater)
SQLDebugger(Limited Account; Password protected)
aspnet_wp account(Limited Account; Password protected)
Guest Account ( Guest Account is off)
at the moment I am in (MyName) account. did you mean that i need to login (aspnet_wp) account and give the permission to the folder and file? or other accounts maybe
cheers!!
Lee
I have reinstalled SDK1.1, it was 1.0. now that permission problem has solved:)
but i have got another problem, this time when i run the application, the errors like:
========================================================
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at uncos.WebForm2.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\uncos\webform2.aspx.cs:line 41
=========================================================
the "Insert Into" is in the WebForm2.aspx
thanks for your guys have been help me!! Cheers
Lee
Please do a research on "Sql Injection Attack". Your code is wide open to this type of attacks.
thanks bleroy, i think i really learned a lot here.
this project won't upload to any server, it is just a practice made by myself. my goal is just insert data into database file from user's input. i didn't really put very much consideration on the security issues. but your advise is valuable for me, thank you very much! Cheers!
i have changed the syntax a little bit, but the problem is still the same.
there is one thing i don't understand, if it is a syntax error, why when i compile it , it didn't give the error warning?
Cheers!
Lee
Thanks for your guys. I had solved my problems. :) I changed the code quite a lot. and it's simplier. it works now,
Cheers!
please help this one is simple
I know how to do it if i compile it, make it a dll file and make it a reference, bu I do not want to do this because i want to beable to edit the code at anytime for some reason i cannot figure out how to accompish this. Seems like it should be very simple?Make a public class named "functions" and all of the methods you want to call "Shared", then include the functions.vb file in the project you want to call them from.
This will allow you call any shared method using the class name . method name from any place in the project.
right now i have functions in a . dll file and i am able to at the top of my code write:
Imports CoreFile.functions
and be able to call methods of the functions class without typing:
CoreFile.functions.GetCookie()
I can just simpley type GetCookie() it seems to me that the Import statement at the top of the code only works with references. is there a way around this? am i doing somthing wrong?
I want to be able to import my functions.vb class
Thanks.
it IS really simple:
if you want to be able to modify your code behind at any time and not have it as a dll then all you need to do is include this at the top of your aspx page:
<%@. Page Inherits="myCodeBehind" src="http://pics.10026.com/?src=myCodeBehind.vb" %>
with this line at the top of your aspx page, you can access any of the functions in your vb file without having it in dll form. just remember to change myCodeBehind.vb to whateveer your codebind.vb page is called.
If you change GetCookie() or any other function inside your functions.vb class you have to re-compile the class and re-compile your application referencing that class (if you want it to access the newly modified functions).
I keep two copies of visual studio open at all times. One has my web application and the other has my functions. Recompile functions, recompile app and now app can access any new functions and the modified functions.
If you think about "how" it works it makes sense. My app references "functions.vb" which is compiled into a DLL and copied into my apps folder. When I re-compile "functions.vb" the newly compiled DLL is still located in it's own base folder. It's not until I re-compile my app that it brings over the new copy of the DLL.
yes that works for a .aspx page but what if i am calling the method from other classes as described above. I can write "Imports CoreFile.functions " at the top of the class
this allows me to call methods of my functions class without writing CoreFile.functions.GetCookie(). Instead I can just write GetCookie() and it recognizes it as CoreFile.functions.GetCookie() is there a way to import a file that is not in references. I want to be able to do something to the effect of "Imports functions.vb" right now it is set as "Imports CoreFile.functions " where CoreFile is a dll defined in references.