Thursday, March 29, 2012

Please advise about caching

Hello,

I tried out using the cache the other day and was impressed with the
concept. I built myself a custom control to generate the site links,
using an XML file for the info. I kept the XML file in the cache and
added a dependency so it will notice when the file changes. All fine so
far.

I was reading last night about using the OutputCache page directive to
store the page in the cache. It seems you can do this for a user control
as well, allowing you to cache part of a page.

So, my question is, which is more appropriate, using the cache manually
or using the OutputCache page directive? Obviously each will have its
uses, but consider the following ...

I have an e-commerce site written in Classic ASP. I am looking to
rewrite it in ASP.NET at some point. One weakness of the existing
version is that product pages are generated dynamically from a database.
I had been looking at a method whereby when the database is updated, the
HTML is created for the product and written to disk, avoiding the
necessity to hit the database each time the page is displayed.

I am now wondering if it would be better to generate the HTML and store
it in the cache. I could either write the part of the page that displays
that product details as a custom control and use OutputCache to cache
that control, or generate the HTML myself and add it manually to the
cache. Either way I would need some mechanism for checking when the
database is updated, but that's a separate issue.

So, any suggestions? Anything to sway me one way or the other?

One factor I would like to consider is the life of an object in the
cache. The OutputCache directive takes a Duration parameter, which means
that come what May, the HTML will be dropped from the cache when it
expires 9if not sooner). If I put it in the cache manually, AFAIK it
will stay there until it gets kicked out for lack of space. Presumably
an object that is called often is less likely to get kicked out, so the
HTML for the most popular products will stay in the cache the longest,
ensuring maximum efficiency. Is this right?

TIA for any comments on this long waffly post ;-)

--
Alan Silver
(anything added below this line is nothing to do with me)Alan:
Generally I like to use OutputCache whenever possible, and storing things in
the HttpCache after. OutputCache caches the entire rendered HTML,
HttpCache.Insert/Add only chunks of data (in other words you still need to
render the output).
In IIS 6.0, outputcache is automatically hosted in the kernel which makes it
even faster. In 2.0 outputcache will be even more flexible AND allow you to
store it to the file which will let it last forever (if you wanted to).

As far as performance, the closer to the final product you can cache
(outputcache) the better. And while I typically don't harp on performance,
that's the point of caching so...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Alan Silver" <alan-silver@.nospam.thanx> wrote in message
news:JLmJ3uERv3CCFwyT@.nospamthankyou.spam...
> Hello,
> I tried out using the cache the other day and was impressed with the
> concept. I built myself a custom control to generate the site links,
> using an XML file for the info. I kept the XML file in the cache and
> added a dependency so it will notice when the file changes. All fine so
> far.
> I was reading last night about using the OutputCache page directive to
> store the page in the cache. It seems you can do this for a user control
> as well, allowing you to cache part of a page.
> So, my question is, which is more appropriate, using the cache manually
> or using the OutputCache page directive? Obviously each will have its
> uses, but consider the following ...
> I have an e-commerce site written in Classic ASP. I am looking to
> rewrite it in ASP.NET at some point. One weakness of the existing
> version is that product pages are generated dynamically from a database.
> I had been looking at a method whereby when the database is updated, the
> HTML is created for the product and written to disk, avoiding the
> necessity to hit the database each time the page is displayed.
> I am now wondering if it would be better to generate the HTML and store
> it in the cache. I could either write the part of the page that displays
> that product details as a custom control and use OutputCache to cache
> that control, or generate the HTML myself and add it manually to the
> cache. Either way I would need some mechanism for checking when the
> database is updated, but that's a separate issue.
> So, any suggestions? Anything to sway me one way or the other?
> One factor I would like to consider is the life of an object in the
> cache. The OutputCache directive takes a Duration parameter, which means
> that come what May, the HTML will be dropped from the cache when it
> expires 9if not sooner). If I put it in the cache manually, AFAIK it
> will stay there until it gets kicked out for lack of space. Presumably
> an object that is called often is less likely to get kicked out, so the
> HTML for the most popular products will stay in the cache the longest,
> ensuring maximum efficiency. Is this right?
> TIA for any comments on this long waffly post ;-)
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>Alan:
>Generally I like to use OutputCache whenever possible, and storing things in
>the HttpCache after. OutputCache caches the entire rendered HTML,
>HttpCache.Insert/Add only chunks of data (in other words you still need to
>render the output).

OK, that's not such a huge problem, it's only a case of pulling it from
the cache and writing it out.

I was more thinking about the issue of how long objects live in the
cache. If I put them in myself, won't they stay there until the cache
gets full? Also, I'm assuming that when objects get dropped form the
cache, the least recently used ones will go first. If so, then the HTML
for the most frequently accessed pages will stay in the cache the
longest, giving the best performance increase.

If I understand the OutputCache right, objects will only stay in the
cache for the time specified. That way, even the frequently accessed
bits will be dropped. This sounds less efficient.

Or have I got it completely wrong ;-)

Thanks for the reply. Any further info would be greatly appreciated.

--
Alan Silver
(anything added below this line is nothing to do with me)
Alan:
I wouldn't say one will last in the cache longer than the other. HttpCache
can also have a time to stay in cache (either as an absolute or a "from last
access"). So in that sense you have more control. I wouldn't make any
assumptions about how/when items are dumped from the cache for two reasons.
First it's probably complicated. Second you shoulnd't assume it's in the
cache technically (ie, it isn't guaranteed to be there, so you need to write
the code to get it form the store if it isn't). Having said that, you can
specify the Priority with HttpCache, again giving you more control, but
adding to the complexity of what/when will be dropped. I would expect a
number of factors to play into the decision, such as priority, time last
used, size, frequency of use, available memory, ....

if you are worried about the duration of output cache, put it as 86400 (a
day)... There's no doubt though that HttpCache provides more flexibility
(priority, absolute vs relative time, dependencies (big one)).

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Alan Silver" <alan-silver@.nospam.thanx> wrote in message
news:MFwoUbGJH5CCFwSE@.nospamthankyou.spam...
> >Alan:
> >Generally I like to use OutputCache whenever possible, and storing things
in
> >the HttpCache after. OutputCache caches the entire rendered HTML,
> >HttpCache.Insert/Add only chunks of data (in other words you still need
to
> >render the output).
> OK, that's not such a huge problem, it's only a case of pulling it from
> the cache and writing it out.
> I was more thinking about the issue of how long objects live in the
> cache. If I put them in myself, won't they stay there until the cache
> gets full? Also, I'm assuming that when objects get dropped form the
> cache, the least recently used ones will go first. If so, then the HTML
> for the most frequently accessed pages will stay in the cache the
> longest, giving the best performance increase.
> If I understand the OutputCache right, objects will only stay in the
> cache for the time specified. That way, even the frequently accessed
> bits will be dropped. This sounds less efficient.
> Or have I got it completely wrong ;-)
> Thanks for the reply. Any further info would be greatly appreciated.
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>Alan:
>I wouldn't say one will last in the cache longer than the other. HttpCache
>can also have a time to stay in cache (either as an absolute or a "from last
>access"). So in that sense you have more control. I wouldn't make any
>assumptions about how/when items are dumped from the cache for two reasons.
>First it's probably complicated. Second you shoulnd't assume it's in the
>cache technically (ie, it isn't guaranteed to be there, so you need to write
>the code to get it form the store if it isn't). Having said that, you can
>specify the Priority with HttpCache, again giving you more control, but
>adding to the complexity of what/when will be dropped. I would expect a
>number of factors to play into the decision, such as priority, time last
>used, size, frequency of use, available memory, ....
>if you are worried about the duration of output cache, put it as 86400 (a
>day)... There's no doubt though that HttpCache provides more flexibility
>(priority, absolute vs relative time, dependencies (big one)).

Thanks for the advice. Maybe I'll just write the code as a custom
control with the OutputCache directive and let .NET handle the hard work
for me!! I can always look at optimising the caching later. From what
you say it sounds like OutputCache is a better option (assuming that
this is what you mean by HttpCache), so I'll use that.

Thanks again

--
Alan Silver
(anything added below this line is nothing to do with me)

Please advise about caching

Hello,
I tried out using the cache the other day and was impressed with the
concept. I built myself a custom control to generate the site links,
using an XML file for the info. I kept the XML file in the cache and
added a dependency so it will notice when the file changes. All fine so
far.
I was reading last night about using the OutputCache page directive to
store the page in the cache. It seems you can do this for a user control
as well, allowing you to cache part of a page.
So, my question is, which is more appropriate, using the cache manually
or using the OutputCache page directive? Obviously each will have its
uses, but consider the following ...
I have an e-commerce site written in Classic ASP. I am looking to
rewrite it in ASP.NET at some point. One weakness of the existing
version is that product pages are generated dynamically from a database.
I had been looking at a method whereby when the database is updated, the
HTML is created for the product and written to disk, avoiding the
necessity to hit the database each time the page is displayed.
I am now wondering if it would be better to generate the HTML and store
it in the cache. I could either write the part of the page that displays
that product details as a custom control and use OutputCache to cache
that control, or generate the HTML myself and add it manually to the
cache. Either way I would need some mechanism for checking when the
database is updated, but that's a separate issue.
So, any suggestions? Anything to sway me one way or the other?
One factor I would like to consider is the life of an object in the
cache. The OutputCache directive takes a Duration parameter, which means
that come what May, the HTML will be dropped from the cache when it
expires 9if not sooner). If I put it in the cache manually, AFAIK it
will stay there until it gets kicked out for lack of space. Presumably
an object that is called often is less likely to get kicked out, so the
HTML for the most popular products will stay in the cache the longest,
ensuring maximum efficiency. Is this right?
TIA for any comments on this long waffly post ;-)
Alan Silver
(anything added below this line is nothing to do with me)Alan:
Generally I like to use OutputCache whenever possible, and storing things in
the HttpCache after. OutputCache caches the entire rendered HTML,
HttpCache.Insert/Add only chunks of data (in other words you still need to
render the output).
In IIS 6.0, outputcache is automatically hosted in the kernel which makes it
even faster. In 2.0 outputcache will be even more flexible AND allow you to
store it to the file which will let it last forever (if you wanted to).
As far as performance, the closer to the final product you can cache
(outputcache) the better. And while I typically don't harp on performance,
that's the point of caching so...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <alan-silver@.nospam.thanx> wrote in message
news:JLmJ3uERv3CCFwyT@.nospamthankyou.spam...
> Hello,
> I tried out using the cache the other day and was impressed with the
> concept. I built myself a custom control to generate the site links,
> using an XML file for the info. I kept the XML file in the cache and
> added a dependency so it will notice when the file changes. All fine so
> far.
> I was reading last night about using the OutputCache page directive to
> store the page in the cache. It seems you can do this for a user control
> as well, allowing you to cache part of a page.
> So, my question is, which is more appropriate, using the cache manually
> or using the OutputCache page directive? Obviously each will have its
> uses, but consider the following ...
> I have an e-commerce site written in Classic ASP. I am looking to
> rewrite it in ASP.NET at some point. One weakness of the existing
> version is that product pages are generated dynamically from a database.
> I had been looking at a method whereby when the database is updated, the
> HTML is created for the product and written to disk, avoiding the
> necessity to hit the database each time the page is displayed.
> I am now wondering if it would be better to generate the HTML and store
> it in the cache. I could either write the part of the page that displays
> that product details as a custom control and use OutputCache to cache
> that control, or generate the HTML myself and add it manually to the
> cache. Either way I would need some mechanism for checking when the
> database is updated, but that's a separate issue.
> So, any suggestions? Anything to sway me one way or the other?
> One factor I would like to consider is the life of an object in the
> cache. The OutputCache directive takes a Duration parameter, which means
> that come what May, the HTML will be dropped from the cache when it
> expires 9if not sooner). If I put it in the cache manually, AFAIK it
> will stay there until it gets kicked out for lack of space. Presumably
> an object that is called often is less likely to get kicked out, so the
> HTML for the most popular products will stay in the cache the longest,
> ensuring maximum efficiency. Is this right?
> TIA for any comments on this long waffly post ;-)
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>Alan:
>Generally I like to use OutputCache whenever possible, and storing things i
n
>the HttpCache after. OutputCache caches the entire rendered HTML,
>HttpCache.Insert/Add only chunks of data (in other words you still need to
>render the output).
OK, that's not such a huge problem, it's only a case of pulling it from
the cache and writing it out.
I was more thinking about the issue of how long objects live in the
cache. If I put them in myself, won't they stay there until the cache
gets full? Also, I'm assuming that when objects get dropped form the
cache, the least recently used ones will go first. If so, then the HTML
for the most frequently accessed pages will stay in the cache the
longest, giving the best performance increase.
If I understand the OutputCache right, objects will only stay in the
cache for the time specified. That way, even the frequently accessed
bits will be dropped. This sounds less efficient.
Or have I got it completely wrong ;-)
Thanks for the reply. Any further info would be greatly appreciated.
Alan Silver
(anything added below this line is nothing to do with me)
Alan:
I wouldn't say one will last in the cache longer than the other. HttpCache
can also have a time to stay in cache (either as an absolute or a "from last
access"). So in that sense you have more control. I wouldn't make any
assumptions about how/when items are dumped from the cache for two reasons.
First it's probably complicated. Second you shoulnd't assume it's in the
cache technically (ie, it isn't guaranteed to be there, so you need to write
the code to get it form the store if it isn't). Having said that, you can
specify the Priority with HttpCache, again giving you more control, but
adding to the complexity of what/when will be dropped. I would expect a
number of factors to play into the decision, such as priority, time last
used, size, frequency of use, available memory, ....
if you are worried about the duration of output cache, put it as 86400 (a
day)... There's no doubt though that HttpCache provides more flexibility
(priority, absolute vs relative time, dependencies (big one)).
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <alan-silver@.nospam.thanx> wrote in message
news:MFwoUbGJH5CCFwSE@.nospamthankyou.spam...
in
to
> OK, that's not such a huge problem, it's only a case of pulling it from
> the cache and writing it out.
> I was more thinking about the issue of how long objects live in the
> cache. If I put them in myself, won't they stay there until the cache
> gets full? Also, I'm assuming that when objects get dropped form the
> cache, the least recently used ones will go first. If so, then the HTML
> for the most frequently accessed pages will stay in the cache the
> longest, giving the best performance increase.
> If I understand the OutputCache right, objects will only stay in the
> cache for the time specified. That way, even the frequently accessed
> bits will be dropped. This sounds less efficient.
> Or have I got it completely wrong ;-)
> Thanks for the reply. Any further info would be greatly appreciated.
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>Alan:
>I wouldn't say one will last in the cache longer than the other. HttpCache
>can also have a time to stay in cache (either as an absolute or a "from las
t
>access"). So in that sense you have more control. I wouldn't make any
>assumptions about how/when items are dumped from the cache for two reasons.
>First it's probably complicated. Second you shoulnd't assume it's in the
>cache technically (ie, it isn't guaranteed to be there, so you need to writ
e
>the code to get it form the store if it isn't). Having said that, you can
>specify the Priority with HttpCache, again giving you more control, but
>adding to the complexity of what/when will be dropped. I would expect a
>number of factors to play into the decision, such as priority, time last
>used, size, frequency of use, available memory, ....
>if you are worried about the duration of output cache, put it as 86400 (a
>day)... There's no doubt though that HttpCache provides more flexibility
>(priority, absolute vs relative time, dependencies (big one)).
Thanks for the advice. Maybe I'll just write the code as a custom
control with the OutputCache directive and let .NET handle the hard work
for me!! I can always look at optimising the caching later. From what
you say it sounds like OutputCache is a better option (assuming that
this is what you mean by HttpCache), so I'll use that.
Thanks again
Alan Silver
(anything added below this line is nothing to do with me)

Please advise me

Hi Everybody,

I am very much novice to .NET.At present i am working in C,Unix Product development.I got no experience in .net infact i am a fresher who is holding months of experience.I am interested in .net development also am anticipating some development works in .net in my firm.

i dont have any knowledge in this domain.and dont know how to start.

Having said by some of my collegues that asp.net and C# are having better oppurtunities today i want to choose the same path to start up my carrer in .Net .

Can any one please kindly advise me how to start up with .net and what meterial to follow?

Awaiting for your response

Thank you

with regards,

Srikanth

Hi,

and welcome to the ASP.NET forums.

You can freely download the VWD Express tool on this site, take the Tutorials and follow the Guided tour. That'll give you some insight. I read that you already developed with C so I would like to advice you to learn C# as your main development language in .NET.

If you're looking for a decent book you can search through the Book reviews forum and if you should have questions you can visit the forums and ask them.

Grz, Kris.

PS: have fun!


Welcome!

Download VWD Express edition from www.asp.net site. In this edition webserver is in built, no need of IIS for development purpose.

To know about asp.net refer following link:

http://samples.gotdotnet.com/quickstart/aspplus/doc/whatisaspx.aspx

If you don't about web programming, I suggest you to read basics ofHTML (tags) , JavaScript (useful for client side programming), .NETframework architecture.

Best of luck.

For any further difficulties in ASP.NET please visit this forum.

:-)

Regards

Kuldeep Deokule.

deokule2003 wrote:

If you don't about web programming, I suggest you to read basics of HTML (tags) , JavaScript (useful for client side programming), .NET framework architecture.

A nice site to learn more about these ishttp://www.w3schools.com/ or you can also take a look at the official documents:http://www.w3.org/TR/.

Grz, Kris.

Please advise on how to create an invoice system

i'm trying to create an asp webform for my own development. I'm trying to create an online invoice where people can enter details like "Customer Name, Address, Date, Total amount".

I'm able to create a webform which captures those details and insert/delete/delete to/from a mssql db.

But because each invoice should have some items, so i created another table (InvoiceDetails) which reference to the Invoice table. So i can create as many items as i want in each invoice.

How should i create webforms for the invoicedetails? Because i need to add dynamically and not fix 10 records to add/edit in the form. THus most probably i'll need to put all sql statements into 1 transaction in case 1 InvoiceDetail record fail, so i can rollback the Invoice and InvoiceDetail record.

are there any samples which has a similar scenario as me?Its an interesting scenario Michael, especially the cardinality of relationship & dynamic nature of this application. If formatting doesn't matter much at data-entry level, you can use editable datagrid to insert/edit/delete data. This will totally accomodate the dynamic nature of InvoiceDetails using this strong data-aware component in ASP.NET. However, for printing & display in invoice report format, you may need to postion the dynamic controls on the fly which may get difficult if positions need customized.

MSDN's article "Adding Controls to a Web Forms Page Programmatically" may help.
http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskaddingcontrolstowebformspageprogrammatically.asp?frame=true

I hope it helps.

-Adnan Masood
This is a job for a new application model. HTML sucks for this stuff. Imagine writing an ERP application for the Web.. Wait Oracle did it.. sort of.

You will probably want to employ some thrd party web controls from the folks at Infragistics. Adding detail lines to invoices without them will be a little kludgy.

I did it once and ended up doing it with a series of frames. A button on the header page took you to a detail page. After adding the data on the detail page you went back to the header. It was a lot of tedious work.
Hmm, I would have a form that adds a single item to the order. Then two buttons, one says "Add another item" and one says "Finish Order". Add another item just reloads the form and Finish Order goes to whatever the next step is.

For editing just use a datalist that binds to the order number.

I do a similar type system for magazine advertising rates for each year. A particular magazine can have 10 years worth of prices and each year can have 20 different rates (for various sizes). The datalist shows all 10 years (queried by the magazine ID) and when they select the edit button it changes all the prices into textboxes for that year only. So your datalist would show all items for a single order, and then allow editing of each individual item inside that order.
hmm... datalist.. but what if its a new invoice? Thus it will not be given a Invoice ID until its inserted into the database. So its kinda hard to bind the individual items to that invoice

thats why i'm asking for advise on whats the best practise for people who has done similar development..
While you are entering the invoice keep the database in some temp tables. Identify the record with a GUID.. after you are done editing copy that data from the temp tables into the production tables. This works well and requires no whacky state management. It depends on the level of sophistication you want. In my current business we don;t start out by entering an order/invoice. We enter contracts the contracts get attached to jobs and several people may be involved with entering the data about the contracts and jobs. As the work on the contract proceeds incremental invoices are issued.

Please answer this question

Please answer this question
You are troubleshooting a deployed Web application and need to change the element to enable tracing on the page. You modify the Web.config file for the application. Which statements correctly describe when the change will be applied and its impact on current users? (Select all that apply.)
0 Current users will be immediately disconnected from the application.
0 Current users will be given a five-minute warning before the Web application is restarted.
0 State data stored in the Application object will be maintained.
0 State data stored in the Session object will be lost.
0 The Web application will be restarted and the configuration file will be read immediately.

Getting others to take your test (or do your homework) for you I see...
tisk tisk.

1) True, but they wont know it till they make a request again.
2) false
3) false
4) false
5) false. It will be "read" on the next request.

Please anyone has confirm message box with yes No buttons in it for asp.net page

Please i am looking for a javascript code to use with confirm message box with two buttons Yes and NO in it.

Thank you very much.How about 'OK' and 'Cancel'?

if that's ok - check out :
http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=confirm
Hello David,
Thank's a lot, I will try the messagebox code.

please can someone explain the following code.

Hi Christian,

Thanks for the reply, but this is what I don't understand.... (by the way
there was a typo in my last message: "dpPageInit" should be "doPageInit").

I am new to inheritance, but I understand that if I create a classA that
inherits from classB then classA will expose properties/methods of classB.
The things I don't understand are code like:

a) override
b) +=
c) this.Init += new System.EventHandler

I am trying to create a page template (ie: a template page that contains a
header and footer), and then I want each of my pages to inherit the template
page so all I have to do is add the main body of the ASP page (the header
and footer will automatically be rendered by the template page).

I have downloaded the code from the following place
http://www.aspnetui.com/templates/ but I cant get it to work when I try it
myself. On top of that I think they have made the example more complex than
it needs to be.

All I want is a template that looks just like their red example. If someone
could post a simplified version of it it would be great.

"Christian" <pleasenononospamcmillotti@dotnet.itags.org.novasoftware.it> wrote in message
news:%23go0RMpVDHA.2316@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
> Hi Suzy
> It seems to me that you are in an inherited class, you are overriding
> virtual method OnInit in order to subscribe dbPageInit to be called in the
> Init Event, dbPageLoad to be called In the Load Event and calling OnInit
> method on base class ( that inherited from )...
> What else aren't you understanding?
> In case give details..
> Christian.
> "suzy" <me@dotnet.itags.org.nospam.com> ha scritto nel messaggio
> news:%23%23Wf4EpVDHA.532@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
> > please can someone explain the following code to a newbie... thanks
> > override protected void OnInit(EventArgs e)
> > {
> > this.Init += new System.EventHandler(dpPageInit);
> > this.Load += new System.EventHandler(doPageLoad);
> > base.OnInit(e);
> > }a) override:
If you have:
Class MyClass
{
...
protected virtual void MyMethod()
{
// Some instructions
...
}
}
MyMethod is the first implementation of the method.
You could have your ownn MyMethod in your class:
Class MySecondClass : Myclass
{
protected override void MyMethod()
{
// other instructions
...
}
}
You can override only virtual methods.

b) += :
add something to... for example:

c) this.Init += new System.EventHandler( doPageInit ):
add doPageInit method to delegate list called by Init event.
( Is Init an event ? )
When Init event is fired your class iterates through delegate: (
System.EventHandler is our delegate )
and call all methods subscribed
you subscribe your own method ( that must have the signature given by
delegate as return type, parameters, etc ) by writng
... += new System.EventHandler( doPageInit ):

Do you know what delegates are?

"suzy" <me@.nospam.com> ha scritto nel messaggio
news:eOF6lbpVDHA.2328@.TK2MSFTNGP12.phx.gbl...
> Hi Christian,
> Thanks for the reply, but this is what I don't understand.... (by the way
> there was a typo in my last message: "dpPageInit" should be "doPageInit").
> I am new to inheritance, but I understand that if I create a classA that
> inherits from classB then classA will expose properties/methods of classB.
> The things I don't understand are code like:
> a) override
> b) +=
> c) this.Init += new System.EventHandler
>
> I am trying to create a page template (ie: a template page that contains a
> header and footer), and then I want each of my pages to inherit the
template
> page so all I have to do is add the main body of the ASP page (the header
> and footer will automatically be rendered by the template page).
> I have downloaded the code from the following place
> http://www.aspnetui.com/templates/ but I cant get it to work when I try it
> myself. On top of that I think they have made the example more complex
than
> it needs to be.
> All I want is a template that looks just like their red example. If
someone
> could post a simplified version of it it would be great.

> > "suzy" <me@.nospam.com> ha scritto nel messaggio
> > news:%23%23Wf4EpVDHA.532@.TK2MSFTNGP09.phx.gbl...
> > > please can someone explain the following code to a newbie... thanks
> > > > override protected void OnInit(EventArgs e)
> > > {
> > > > this.Init += new System.EventHandler(dpPageInit);
> > > this.Load += new System.EventHandler(doPageLoad);
> > > base.OnInit(e);
> > > }
> >
> Thanks for your reply. No I don't know what delegates are. :-(

should take a look..
> Also, in your example of MyClass/MyMethod in which order will the code be
> run?
MyClass.MyMethod is 1 implementation
MySecondClass.MyMethod is another 1
they are not tied
public Class MyClass
{
...
protected virtual void MyMethod()
{
// Some instructions
MessageBox.Show( "1" );
}
protected virtual void AnotherMethod()
{
MessageBox.Show( "Hello" );
}
}
MyMethod is the first implementation of the method.
You could have your ownn MyMethod in your class:
public Class MySecondClass : Myclass
{
protected override void MyMethod()
{
// other instructions
MessageBox.Show( "2" );
...
}
protectd override AnotherMethod()
{
base.AnotherMethod();
MessageBox.Show( "Suzy" );
}
}
MyClass cl = new MyClass();
cl.MyMethod(); // displays 1
cl.AnotherMethod(); // displays Hello
MySecondClass cl2 = new MySecondClass();
cl2.MyMethod(); // displays 2
cl2.AnotherMethod(); // displays Hello and then Suzy

talking about delegates and events

this.Load += new System.EventHandler(doPageLoad);
this.Load += new System.EventHandler(doPageAnotherLoad);
this.Load += new System.EventHandler(doPageAnotherOneLoad);

On Load Fired will be executed
doPageLoad(), doPageAnotherLoad(), doPageAnotherOneLoad(), i think in order
of submission

> Someone said the following code would create a template if placed in a
page
> template class:
Sorry, i'm not the proper person for help you with asp... never worked :-(
Repost for detailed and specific helps.

> protected override void OnInit (EventArgs args)
> {
> this.Controls.AddAt(0, LoadControl("path to header.ascx " );
> base.OnInit(e);
> this.Controls.Add(LoadControl("path to footer.ascx"));
> }
> And the code in my page that inherited the above contained the
following...:
> override protected void OnInit(EventArgs e)
> {
> InitializeComponent();
> base.OnInit(e);
> }
> private void Page_Load(object sender, System.EventArgs e)
> {
> placeholder.Controls.Add (grdDataGrid);
> }
> They said this should place my placeholder/datagrid between a
header/footer.
Thanks, that explains a lot! Much appreciated!

I think I am right in saying that if I inherited a template class containing
the code below in it, then it won't place a header/footer around my ASP code
(of the page that inherits the template class).

protected override void OnInit (EventArgs args)
{
this.Controls.AddAt(0, LoadControl("path to header.ascx" );
base.OnInit(e);
this.Controls.Add(LoadControl("path to footer.ascx"));
}

"Tom" <TomRemoveThisClement@.sbcglobal.net> wrote in message
news:uMKACrzVDHA.2156@.TK2MSFTNGP11.phx.gbl...
> Hi Susy,
> A delegate (or an event) is an kind of pointer to functions. The
difference
> between an event and an ordinary pointer is that inside of the event is a
> list of pointers to functions. If you "call" the event it's called
raising
> the event and every function that has been added to the event is called in
> order.
> The way this is typicaly used in C# is if you have a class in which things
> can occur that might be of interest to others, you can declare a public
> event (like "event EventHandler Load;") Any other object that is
interested
> in (i.e wants to be notified of) this occurance (Load) registers this
> interest by adding a pointer to a function in the event. So when you see
> the code:
> this.Load += new System.EventHandler(doPageLoad);
> you are looking at an expression of interest in the Load event. When it
> occurs, the doPageLoad() function will be called (along with any other
> functions that have been registered with the Load event using the +=
syntax.
> The odd thing about this code is that it it registering with an event on
the
> same object as the current instance. There are better (or at least more
> natural) ways of accomplishing this. First, if (as is likely) the Load
> event is declared in a superclass (a class from which this current class
was
> derived - directly or indirectly) you would typically override a protected
> OnLoad() method to obtain the notification of Load. Second, if the event
is
> declared in the same object as the += code, you'd typically just call a
> function directly instead of raising an event and receiving notification
for
> it.
> Tom
> "suzy" <me@.nospam.com> wrote in message
> news:%23PoQfkrVDHA.3088@.tk2msftngp13.phx.gbl...
> > great, i am starting to understand more:
> > i thought it worked the way you say it worked, that's why i didn't
> > understand the theory behind he code that was submitted to me regarding
> the
> > page hearder/footer (shown below):
> > > protected override void OnInit (EventArgs args)
> > > {
> > > this.Controls.AddAt(0, LoadControl("path to header.ascx " );
> > > base.OnInit(e);
> > > this.Controls.Add(LoadControl("path to footer.ascx"));
> > > }
> > if the above code is in my base/template class (A), i can't see how i
can
> > write code in a class that inherits from it (B), so that my code from B
> gets
> > inserted between the header/footer.
> > i know you said you haven't done asp.net, but doesn't the theory of it
> sound
> > wrong to you?
> > "Christian" <pleasenononospamcmillotti@.novasoftware.it> wrote in message
> > news:uE5jGJrVDHA.532@.TK2MSFTNGP10.phx.gbl...
> > > > > Thanks for your reply. No I don't know what delegates are. :-(
> > > > should take a look..
> > > > > > Also, in your example of MyClass/MyMethod in which order will the
code
> > be
> > > > run?
> > > MyClass.MyMethod is 1 implementation
> > > MySecondClass.MyMethod is another 1
> > > they are not tied
> > > public Class MyClass
> > > {
> > > ...
> > > protected virtual void MyMethod()
> > > {
> > > // Some instructions
> > > MessageBox.Show( "1" );
> > > }
> > > protected virtual void AnotherMethod()
> > > {
> > > MessageBox.Show( "Hello" );
> > > }
> > > }
> > > MyMethod is the first implementation of the method.
> > > You could have your ownn MyMethod in your class:
> > > public Class MySecondClass : Myclass
> > > {
> > > protected override void MyMethod()
> > > {
> > > // other instructions
> > > MessageBox.Show( "2" );
> > > ...
> > > }
> > > protectd override AnotherMethod()
> > > {
> > > base.AnotherMethod();
> > > MessageBox.Show( "Suzy" );
> > > }
> > > }
> > > MyClass cl = new MyClass();
> > > cl.MyMethod(); // displays 1
> > > cl.AnotherMethod(); // displays Hello
> > > MySecondClass cl2 = new MySecondClass();
> > > cl2.MyMethod(); // displays 2
> > > cl2.AnotherMethod(); // displays Hello and then Suzy
> > > > talking about delegates and events
> > > > this.Load += new System.EventHandler(doPageLoad);
> > > this.Load += new System.EventHandler(doPageAnotherLoad);
> > > this.Load += new System.EventHandler(doPageAnotherOneLoad);
> > > > On Load Fired will be executed
> > > doPageLoad(), doPageAnotherLoad(), doPageAnotherOneLoad(), i think in
> > order
> > > of submission
> > > > > > > Someone said the following code would create a template if placed in
a
> > > page
> > > > template class:
> > > Sorry, i'm not the proper person for help you with asp... never worked
> :-(
> > > Repost for detailed and specific helps.
> > > > > protected override void OnInit (EventArgs args)
> > > > {
> > > > this.Controls.AddAt(0, LoadControl("path to header.ascx " );
> > > > base.OnInit(e);
> > > > this.Controls.Add(LoadControl("path to footer.ascx"));
> > > > }
> > > > > > And the code in my page that inherited the above contained the
> > > following...:
> > > > > > override protected void OnInit(EventArgs e)
> > > > > > {
> > > > > > InitializeComponent();
> > > > > > base.OnInit(e);
> > > > > > }
> > > > > > private void Page_Load(object sender, System.EventArgs e)
> > > > > > {
> > > > > > placeholder.Controls.Add (grdDataGrid);
> > > > > > }
> > > > > > They said this should place my placeholder/datagrid between a
> > > header/footer.
> > > >

Please change my readonly (Enabled=false) checkbox style as it is difficult to read.

Hi,

This has been bugging me for a while so any help is appreciated.

How do I change the style of a readonly checkbox? (i.e. Enabled = False) - it's very difficult to read

I am displaying a set of checkbox based on some database query which works fine - however the faded checkbox and tick are not easy to see. I don't want to use skin files/themes if I can help it.

The only option I can think of is to display the database results (1 or 0) as images (1 for empty checkbox and 1 for full checkbox) but it seems a bit over the top.

I may be missing something simple but I have tried various checkbox parameter settings to no avail.

Many thanks

MrCadburysParrot

I had the same concern and I wound up using images. Over the top? That's all I could get working...

 <asp:TemplateField HeaderText="Freeze Definition" SortExpression="FreezeDefn"> <ItemTemplate> <asp:Image ImageUrl="../../images/CheckBoxYes.gif" ID="imgFreezeDefnTrue" runat="server" Visible='<%# Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:Image> <asp:Image ImageUrl="../../images/CheckBoxNo.gif" ID="imgFreezeDefnFalse" runat="server" Visible='<%# !Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:Image> </ItemTemplate> <EditItemTemplate> <asp:CheckBox ID="cbxFreezeDefn" runat="server" checked='<%# Convert.ToBoolean(Eval("FreezeDefn"))%>'> </asp:CheckBox> </EditItemTemplate> <FooterTemplate> <asp:CheckBox ID="cbxNewFreezeDefn" runat="server" > </asp:CheckBox> </FooterTemplate> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" Width="120px" Wrap="True" /> <FooterStyle HorizontalAlign="Center" /> </asp:TemplateField>

Hi,

Thanks for the response. It does seem the only way to do it. I ended up using

<asp:ImageID="chkD7Adjusted"runat="server"ImageUrl='<%# DisplayCheckGraphic(Eval("Interlocks")) %>'/>

The function DisplayCheckGraphic then returns a string value (depending on the Interlocks value) denoting the appropriate Image URL.

I'll leave the post running for a few days to see if anyone has a direct answer to the checkbox issue - if not I will allocate your response as the answer as it was same as the method that I am currently using.

Thanks

MrCadburysParrot


You can do many things such as setting style etc around it.

one way is to

Get the checked event in javascript and then

e.ParentNode.style.border =(e.checked ? 'outset' :' ' );

or for a simple readonly setting its style to outset, so that it becomes raised.


Yeah, you could stick it on the stylesheet too. That would be much neater. I'm not a designer though so I don't do much with styles beyong making something readable. I really would like to put some time into sexy-ing up my pages but I'm too busy developing functionality and working on ETL and such. So is everyone else on the team - the guy with the design skills is busy writing code generators.

Plus I can't stand CSS language. Why is it different than the syntax used for styles in ASP? The don't even have the same attributes... grr. Does silverlight encapsulate this kind of stuff by any chance? Is there something on the horizon that will give us a styling GUI? Thanks.


Charles Asbornsen:

Yeah, you could stick it on the stylesheet too. That would be much neater. I'm not a designer though so I don't do much with styles beyong making something readable. I really would like to put some time into sexy-ing up my pages but I'm too busy developing functionality and working on ETL and such. So is everyone else on the team - the guy with the design skills is busy writing code generators.

Plus I can't stand CSS language. Why is it different than the syntax used for styles in ASP? The don't even have the same attributes... grr. Does silverlight encapsulate this kind of stuff by any chance? Is there something on the horizon that will give us a styling GUI? Thanks.

Charles

CSS is a standard and rather a markup where as Asp.net is a framework and CSS existed way before Asp.net and imagine sugar and water cannot be same thing, however sugar provides sweetness to water. Silverlight is imagine a plugin like flash and CSS will still be at play. Yes there are skins but they also work with cSS.

Best regards


A poetic allusion for a buggering annoyance. Big Smile I appreciate the "objectiness" of CSS (kind of like truthiness), and I'd like to go through all my code and CSS the whole works, but that has to wait until all our deliverables are, um, delivered. I could really use some CSS training. I just wish I could go to something like powerpoint, draw my styled control in that, and then say "hey you, this is your style when selected, and this is your style when mouseover" and so forth without 28 lines of code...

Please clarify how null nodeset result processes?

Hi, I continue to have trouble with this. Using the following xml
sample:

<Station name="Station1" line_stop="yes"/
OR when NO line_stop attribute exists.

In asp.net page, I use xpath to determine IF the line_stop attribute
exists (or am TRYING to!)

Dim xDoc as XmlDocument
Dim xNode As XmlElement =
xDoc.SelectSingleNode("//Station[@dotnet.itags.org.name='Station1'][@dotnet.itags.org.line_stop='yes']")

If Not xNode.Value Is Nothing Then
If xNode.Value = "yes" Then
do this...
End If
End If

If there is no line_stop attribute, I get an error for "Object reference
not set to an instance of an object" at the If Not xNode.Value
line...obviously returning no node.

Please tell me where I'm going wrong.

Thanks,
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Kathy, you might get better responses in the .framework group, since this
doesn't seem to be specific to ASP.NET.

--
John Saunders
Internet Engineer
john.saunders@.surfcontrol.com

"Kathy Burke" <kathyburke40@.attbi.com> wrote in message
news:%23xJL5a0aDHA.2412@.TK2MSFTNGP10.phx.gbl...
> Hi, I continue to have trouble with this. Using the following xml
> sample:
> <Station name="Station1" line_stop="yes"/>
> OR when NO line_stop attribute exists.
> In asp.net page, I use xpath to determine IF the line_stop attribute
> exists (or am TRYING to!)
> Dim xDoc as XmlDocument
> Dim xNode As XmlElement =
> xDoc.SelectSingleNode("//Station[@.name='Station1'][@.line_stop='yes']")
> If Not xNode.Value Is Nothing Then
> If xNode.Value = "yes" Then
> do this...
> End If
> End If
> If there is no line_stop attribute, I get an error for "Object reference
> not set to an instance of an object" at the If Not xNode.Value
> line...obviously returning no node.
> Please tell me where I'm going wrong.
> Thanks,
> Kathy
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
check if the xNode is nothing first

"Kathy Burke" <kathyburke40@.attbi.com> wrote in message
news:%23xJL5a0aDHA.2412@.TK2MSFTNGP10.phx.gbl...
> Hi, I continue to have trouble with this. Using the following xml
> sample:
> <Station name="Station1" line_stop="yes"/>
> OR when NO line_stop attribute exists.
> In asp.net page, I use xpath to determine IF the line_stop attribute
> exists (or am TRYING to!)
> Dim xDoc as XmlDocument
> Dim xNode As XmlElement =
> xDoc.SelectSingleNode("//Station[@.name='Station1'][@.line_stop='yes']")
> If Not xNode.Value Is Nothing Then
> If xNode.Value = "yes" Then
> do this...
> End If
> End If
> If there is no line_stop attribute, I get an error for "Object reference
> not set to an instance of an object" at the If Not xNode.Value
> line...obviously returning no node.
> Please tell me where I'm going wrong.
> Thanks,
> Kathy
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Doesn't "If Not xNode.Value Is Nothing Then" check that xNode is
nothing?

Thanks.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"Kathy Burke" <kathyburke40@.attbi.com> wrote in message
news:ei17Bx0aDHA.2024@.TK2MSFTNGP12.phx.gbl...
> Doesn't "If Not xNode.Value Is Nothing Then" check that xNode is
> nothing?

No. That checks to see if xNode.Value is Nothing. If xNode is Nothing, the
above "If" statement will throw a NullReferenceException.

To see if xNode is Nothing try:

If Not xNode is Nothing Then

--
John Saunders
Internet Engineer
john.saunders@.surfcontrol.com
Hi again,

I've tried adding:

If Not n16 Is Nothing Then
If n16.Value = "yes" Then
Dim strNext As String = "yes"
End If
End If

but still get a NullReferenceException on the first line of the above
snippet. In this particular case, I SHOULD get "nothing" as a result
since the attribute 'line_stop' doesn't exist for the element
selected...but the code should then continue, yes?

Any suggestions for how I can proceed?

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Please check....~~

My friend wrote me an asp mail, it's written for a flash mail, but the mail cant be deliver to mailbox...can you help me check that is there any errors in this asp form? Thxxx

<%
On Error resume Next
Dim TBdy
Dim MyCDO
CR = Chr(13)
Set MyCDO = Server.CreateObject("CDONTS.NewMail")
If IsObject (MyCDO) Then
MyCDO.From = Request("email")
MyCDO.To = "mymail@dotnet.itags.org.abc.com"
MyCDO.Subject = "Contact Form"
TBdy = "Name: " & Request("name") & CR
TBdy = TBdy & "Contact Number: " & Request("contact") & CR
TBdy = TBdy & "Company Name: " & Request("company") & CR
TBdy = TBdy & "Company Address: " & Request("address") & CR
TBdy = TBdy & "City: " & Request("city") & CR
TBdy = TBdy & "Postcode: " & Request("postcode") & CR
TBdy = TBdy & "Country: " & Request("country") & CR
TBdy = TBdy & "Enquiry About: " & Request("enquiry") & CR
TBdy = TBdy & "Contact Email: " & Request("email") & CR
TBdy = TBdy & "Enquiry/Comment: " & Request("comment")
MyCDO.Body = TBdy
MyCDO.Importance = 2 (High)
MyCDO.Send
Set MyCDO = nothing
Response.Write("&bool=success&")
Else
Response.Write("&bool=failed&")
End If
%>Welcome to the ASP.NET Forums, bunko.

However, you are in the wrong place. These forums are for developers using ASP.NET.

As you are using classic ASP, you need to direct all your questions to theASP Messageboard.
oopppssss...sorrie... wrong place.. :p

please check this link http://www.kerala.bsnl.co.in/newdqasp/newdq1.asp

http://www.kerala.bsnl.co.in/newdqasp/newdq1.asp

when the mouse is over the thariff menu the menu will be listed but the drop down list is just over the menu any solutions to solve this..

are you saying you want the popupmenu to appear slightly lower? It looks like when the mouse goes over the menu item a function call MM_ShowMenu is called and this takes coordinates for where to display the menu. Try changing

<A id=link14 onmouseout=MM_startTimeout();
onmouseover="MM_showMenu(window.mm_menu_0611164247_0,0,16,null,'link15')"
name=link15>TARIFF</A>

To

<A id=link14 onmouseout=MM_startTimeout();
onmouseover="MM_showMenu(window.mm_menu_0611164247_0,0,25,null,'link15')"
name=link15>TARIFF</A>

Not really sure what it will do as I'm unable to test it here but give it a go.


i wanted the menu to be on top of dropdown list insted of showing the dropdown list betwen the menu.


Hi,

I notice something abt the site... When u click the dropdownlist and dun select anything, then mouse to ur menu the dropdownlist still appear... Which dun look gd


what should i do to overcome this problem

Please check code - need to make generic

Hello -
This code was snagged by me from the Internet and altered. Its purpose is
to check for swear words. It works the way it currently is, but I need it t
o
be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
directly; I want to be able to plug in the name of any textbox into
CheckString(TextBox1.Text), instead of just a specific textbox. [I have man
y
textboxes on one page that all need to be checked.]
Public Sub CheckString(inputstring as string)
Dim alWordList as New ArrayList
Dim origtext as String
origtext = TextBox1.Text
dim xmlDocPath as string = server.mappath("bad_words2.xml")
dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
While (xmlReader.Read())
if xmlReader.Nodetype=xmlNodeType.Text then
alWordList.Add(xmlReader.Value)
End If
End While
xmlReader.Close()
Dim r as Regex
dim element as string
dim output as string
For Each element in alWordList
r = New Regex("\b" & element)
InputString = r.Replace(InputString, "****")
Next
TextBox1.Text = InputString
If origtext <> TextBox1.Text Then
Label1.Text = "Funky words, please replace."
Else
Label1.Text = "Okay." 'This is just included for testing
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
CheckString(TextBox1.Text)
End Sub
Any suggestions will be greatly appreciated!
--
SandyHi Sandy,
You can try
Public Sub CheckString(txtBox As TextBox, lbl As Label)
Dim alWordList as New ArrayList
Dim inputstring as string = txtBox.Text
Dim origtext as String = inputstring
dim xmlDocPath as string = server.mappath("bad_words2.xml")
dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
While (xmlReader.Read())
if xmlReader.Nodetype=xmlNodeType.Text then
alWordList.Add(xmlReader.Value)
End If
End While
xmlReader.Close()
Dim r as Regex
dim element as string
dim output as string
For Each element in alWordList
r = New Regex("\b" & element)
inputString = r.Replace(inputString, "****")
Next
txtBox.Text = inputString
If Not origtext.Equals(inputString) Then
lbl.Text = "Funky words, please replace."
Else
lbl.Text = "Okay." 'This is just included for testing
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
CheckString(TextBox1, Label1)
End Sub
"Sandy" wrote:

> Hello -
> This code was snagged by me from the Internet and altered. Its purpose is
> to check for swear words. It works the way it currently is, but I need it
to
> be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I have m
any
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
You could achieve this by e.g. creating a new class with a static
method called
public static bool CheckString( string input, string censoredString )
that returns a bool indicating whether it had to censor the string.
The censored string is written into the second string reference you
pass.
Since I am not familiar with VB, here is the C# for that.
public class SwearWordChecker{
public static string CheckString( string input, string censoredString
){
censoredString = input;
// do your thing here
..
censoredString = r.Replace(InputString, "****");
..
//if they are the same, return true
return (input == censoredString);
}
}
and then use that class in your Button code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
string censored = null;
if( !CheckString(TextBox1.Text, censored) ){
TextBox1.Text = censored;
lblError.Text = "You cursing sombitch."
}
End Sub
Hope this helps.
Manuel
Sandy wrote:
> Hello -
> This code was snagged by me from the Internet and altered. Its
purpose is
> to check for swear words. It works the way it currently is, but I
need it to
> be more generic -- i.e., I don't want it to refer to TextBox1 or
Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I
have many
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
Thanks so much, Elton. It works beautifully!
Sandy
"Elton W" wrote:
> Hi Sandy,
> You can try
> Public Sub CheckString(txtBox As TextBox, lbl As Label)
> Dim alWordList as New ArrayList
> Dim inputstring as string = txtBox.Text
> Dim origtext as String = inputstring
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> inputString = r.Replace(inputString, "****")
> Next
> txtBox.Text = inputString
> If Not origtext.Equals(inputString) Then
> lbl.Text = "Funky words, please replace."
> Else
> lbl.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1, Label1)
> End Sub
>
> "Sandy" wrote:
>
Thanks for your response!
Sandy
"DoesDotNet" wrote:

> You could achieve this by e.g. creating a new class with a static
> method called
> public static bool CheckString( string input, string censoredString )
> that returns a bool indicating whether it had to censor the string.
> The censored string is written into the second string reference you
> pass.
> Since I am not familiar with VB, here is the C# for that.
> public class SwearWordChecker{
> public static string CheckString( string input, string censoredString
> ){
> censoredString = input;
> // do your thing here
> ...
> censoredString = r.Replace(InputString, "****");
> ...
> //if they are the same, return true
> return (input == censoredString);
> }
> }
> and then use that class in your Button code:
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> string censored = null;
> if( !CheckString(TextBox1.Text, censored) ){
> TextBox1.Text = censored;
> lblError.Text = "You cursing sombitch."
> }
> End Sub
> Hope this helps.
> Manuel
>
> Sandy wrote:
> purpose is
> need it to
> Label1
> have many
>

Please check code - need to make generic

Hello -

This code was snagged by me from the Internet and altered. Its purpose is
to check for swear words. It works the way it currently is, but I need it to
be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
directly; I want to be able to plug in the name of any textbox into
CheckString(TextBox1.Text), instead of just a specific textbox. [I have many
textboxes on one page that all need to be checked.]

Public Sub CheckString(inputstring as string)
Dim alWordList as New ArrayList

Dim origtext as String
origtext = TextBox1.Text

dim xmlDocPath as string = server.mappath("bad_words2.xml")
dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
While (xmlReader.Read())
if xmlReader.Nodetype=xmlNodeType.Text then
alWordList.Add(xmlReader.Value)
End If
End While
xmlReader.Close()

Dim r as Regex
dim element as string
dim output as string
For Each element in alWordList
r = New Regex("\b" & element)
InputString = r.Replace(InputString, "****")
Next

TextBox1.Text = InputString
If origtext <> TextBox1.Text Then
Label1.Text = "Funky words, please replace."
Else
Label1.Text = "Okay." 'This is just included for testing
End If
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
CheckString(TextBox1.Text)
End Sub

Any suggestions will be greatly appreciated!
--
SandyHi Sandy,

You can try

Public Sub CheckString(txtBox As TextBox, lbl As Label)
Dim alWordList as New ArrayList
Dim inputstring as string = txtBox.Text
Dim origtext as String = inputstring

dim xmlDocPath as string = server.mappath("bad_words2.xml")
dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
While (xmlReader.Read())
if xmlReader.Nodetype=xmlNodeType.Text then
alWordList.Add(xmlReader.Value)
End If
End While
xmlReader.Close()

Dim r as Regex
dim element as string
dim output as string
For Each element in alWordList
r = New Regex("\b" & element)
inputString = r.Replace(inputString, "****")
Next

txtBox.Text = inputString
If Not origtext.Equals(inputString) Then
lbl.Text = "Funky words, please replace."
Else
lbl.Text = "Okay." 'This is just included for testing
End If
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
CheckString(TextBox1, Label1)
End Sub

"Sandy" wrote:

> Hello -
> This code was snagged by me from the Internet and altered. Its purpose is
> to check for swear words. It works the way it currently is, but I need it to
> be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I have many
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
Hi Sandy,

You can try

Public Sub CheckString(txtBox As TextBox, lbl As Label)
Dim alWordList as New ArrayList
Dim inputstring as string = txtBox.Text
Dim origtext as String = inputstring

dim xmlDocPath as string = server.mappath("bad_words2.xml")
dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
While (xmlReader.Read())
if xmlReader.Nodetype=xmlNodeType.Text then
alWordList.Add(xmlReader.Value)
End If
End While
xmlReader.Close()

Dim r as Regex
dim element as string
dim output as string
For Each element in alWordList
r = New Regex("\b" & element)
inputString = r.Replace(inputString, "****")
Next

txtBox.Text = inputString
If Not origtext.Equals(inputString) Then
lbl.Text = "Funky words, please replace."
Else
lbl.Text = "Okay." 'This is just included for testing
End If
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
CheckString(TextBox1, Label1)
End Sub

"Sandy" wrote:

> Hello -
> This code was snagged by me from the Internet and altered. Its purpose is
> to check for swear words. It works the way it currently is, but I need it to
> be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I have many
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
You could achieve this by e.g. creating a new class with a static
method called

public static bool CheckString( string input, string censoredString )

that returns a bool indicating whether it had to censor the string.
The censored string is written into the second string reference you
pass.
Since I am not familiar with VB, here is the C# for that.

public class SwearWordChecker{
public static string CheckString( string input, string censoredString
){
censoredString = input;
// do your thing here
...
censoredString = r.Replace(InputString, "****");
...
//if they are the same, return true
return (input == censoredString);
}
}

and then use that class in your Button code:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
string censored = null;
if( !CheckString(TextBox1.Text, censored) ){
TextBox1.Text = censored;
lblError.Text = "You cursing sombitch."
}
End Sub

Hope this helps.
Manuel

Sandy wrote:
> Hello -
> This code was snagged by me from the Internet and altered. Its
purpose is
> to check for swear words. It works the way it currently is, but I
need it to
> be more generic -- i.e., I don't want it to refer to TextBox1 or
Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I
have many
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
You could achieve this by e.g. creating a new class with a static
method called

public static bool CheckString( string input, string censoredString )

that returns a bool indicating whether it had to censor the string.
The censored string is written into the second string reference you
pass.
Since I am not familiar with VB, here is the C# for that.

public class SwearWordChecker{
public static string CheckString( string input, string censoredString
){
censoredString = input;
// do your thing here
...
censoredString = r.Replace(InputString, "****");
...
//if they are the same, return true
return (input == censoredString);
}
}

and then use that class in your Button code:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
string censored = null;
if( !CheckString(TextBox1.Text, censored) ){
TextBox1.Text = censored;
lblError.Text = "You cursing sombitch."
}
End Sub

Hope this helps.
Manuel

Sandy wrote:
> Hello -
> This code was snagged by me from the Internet and altered. Its
purpose is
> to check for swear words. It works the way it currently is, but I
need it to
> be more generic -- i.e., I don't want it to refer to TextBox1 or
Label1
> directly; I want to be able to plug in the name of any textbox into
> CheckString(TextBox1.Text), instead of just a specific textbox. [I
have many
> textboxes on one page that all need to be checked.]
> Public Sub CheckString(inputstring as string)
> Dim alWordList as New ArrayList
> Dim origtext as String
> origtext = TextBox1.Text
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> InputString = r.Replace(InputString, "****")
> Next
> TextBox1.Text = InputString
> If origtext <> TextBox1.Text Then
> Label1.Text = "Funky words, please replace."
> Else
> Label1.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1.Text)
> End Sub
> Any suggestions will be greatly appreciated!
> --
> Sandy
Thanks so much, Elton. It works beautifully!

Sandy

"Elton W" wrote:

> Hi Sandy,
> You can try
> Public Sub CheckString(txtBox As TextBox, lbl As Label)
> Dim alWordList as New ArrayList
> Dim inputstring as string = txtBox.Text
> Dim origtext as String = inputstring
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> inputString = r.Replace(inputString, "****")
> Next
> txtBox.Text = inputString
> If Not origtext.Equals(inputString) Then
> lbl.Text = "Funky words, please replace."
> Else
> lbl.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1, Label1)
> End Sub
>
> "Sandy" wrote:
> > Hello -
> > This code was snagged by me from the Internet and altered. Its purpose is
> > to check for swear words. It works the way it currently is, but I need it to
> > be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
> > directly; I want to be able to plug in the name of any textbox into
> > CheckString(TextBox1.Text), instead of just a specific textbox. [I have many
> > textboxes on one page that all need to be checked.]
> > Public Sub CheckString(inputstring as string)
> > Dim alWordList as New ArrayList
> > Dim origtext as String
> > origtext = TextBox1.Text
> > dim xmlDocPath as string = server.mappath("bad_words2.xml")
> > dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> > While (xmlReader.Read())
> > if xmlReader.Nodetype=xmlNodeType.Text then
> > alWordList.Add(xmlReader.Value)
> > End If
> > End While
> > xmlReader.Close()
> > Dim r as Regex
> > dim element as string
> > dim output as string
> > For Each element in alWordList
> > r = New Regex("\b" & element)
> > InputString = r.Replace(InputString, "****")
> > Next
> > TextBox1.Text = InputString
> > If origtext <> TextBox1.Text Then
> > Label1.Text = "Funky words, please replace."
> > Else
> > Label1.Text = "Okay." 'This is just included for testing
> > End If
> > End Sub
> > Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > CheckString(TextBox1.Text)
> > End Sub
> > Any suggestions will be greatly appreciated!
> > --
> > Sandy
Thanks so much, Elton. It works beautifully!

Sandy

"Elton W" wrote:

> Hi Sandy,
> You can try
> Public Sub CheckString(txtBox As TextBox, lbl As Label)
> Dim alWordList as New ArrayList
> Dim inputstring as string = txtBox.Text
> Dim origtext as String = inputstring
> dim xmlDocPath as string = server.mappath("bad_words2.xml")
> dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> While (xmlReader.Read())
> if xmlReader.Nodetype=xmlNodeType.Text then
> alWordList.Add(xmlReader.Value)
> End If
> End While
> xmlReader.Close()
> Dim r as Regex
> dim element as string
> dim output as string
> For Each element in alWordList
> r = New Regex("\b" & element)
> inputString = r.Replace(inputString, "****")
> Next
> txtBox.Text = inputString
> If Not origtext.Equals(inputString) Then
> lbl.Text = "Funky words, please replace."
> Else
> lbl.Text = "Okay." 'This is just included for testing
> End If
> End Sub
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> CheckString(TextBox1, Label1)
> End Sub
>
> "Sandy" wrote:
> > Hello -
> > This code was snagged by me from the Internet and altered. Its purpose is
> > to check for swear words. It works the way it currently is, but I need it to
> > be more generic -- i.e., I don't want it to refer to TextBox1 or Label1
> > directly; I want to be able to plug in the name of any textbox into
> > CheckString(TextBox1.Text), instead of just a specific textbox. [I have many
> > textboxes on one page that all need to be checked.]
> > Public Sub CheckString(inputstring as string)
> > Dim alWordList as New ArrayList
> > Dim origtext as String
> > origtext = TextBox1.Text
> > dim xmlDocPath as string = server.mappath("bad_words2.xml")
> > dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> > While (xmlReader.Read())
> > if xmlReader.Nodetype=xmlNodeType.Text then
> > alWordList.Add(xmlReader.Value)
> > End If
> > End While
> > xmlReader.Close()
> > Dim r as Regex
> > dim element as string
> > dim output as string
> > For Each element in alWordList
> > r = New Regex("\b" & element)
> > InputString = r.Replace(InputString, "****")
> > Next
> > TextBox1.Text = InputString
> > If origtext <> TextBox1.Text Then
> > Label1.Text = "Funky words, please replace."
> > Else
> > Label1.Text = "Okay." 'This is just included for testing
> > End If
> > End Sub
> > Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > CheckString(TextBox1.Text)
> > End Sub
> > Any suggestions will be greatly appreciated!
> > --
> > Sandy
Thanks for your response!

Sandy

"DoesDotNet" wrote:

> You could achieve this by e.g. creating a new class with a static
> method called
> public static bool CheckString( string input, string censoredString )
> that returns a bool indicating whether it had to censor the string.
> The censored string is written into the second string reference you
> pass.
> Since I am not familiar with VB, here is the C# for that.
> public class SwearWordChecker{
> public static string CheckString( string input, string censoredString
> ){
> censoredString = input;
> // do your thing here
> ...
> censoredString = r.Replace(InputString, "****");
> ...
> //if they are the same, return true
> return (input == censoredString);
> }
> }
> and then use that class in your Button code:
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> string censored = null;
> if( !CheckString(TextBox1.Text, censored) ){
> TextBox1.Text = censored;
> lblError.Text = "You cursing sombitch."
> }
> End Sub
> Hope this helps.
> Manuel
>
> Sandy wrote:
> > Hello -
> > This code was snagged by me from the Internet and altered. Its
> purpose is
> > to check for swear words. It works the way it currently is, but I
> need it to
> > be more generic -- i.e., I don't want it to refer to TextBox1 or
> Label1
> > directly; I want to be able to plug in the name of any textbox into
> > CheckString(TextBox1.Text), instead of just a specific textbox. [I
> have many
> > textboxes on one page that all need to be checked.]
> > Public Sub CheckString(inputstring as string)
> > Dim alWordList as New ArrayList
> > Dim origtext as String
> > origtext = TextBox1.Text
> > dim xmlDocPath as string = server.mappath("bad_words2.xml")
> > dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> > While (xmlReader.Read())
> > if xmlReader.Nodetype=xmlNodeType.Text then
> > alWordList.Add(xmlReader.Value)
> > End If
> > End While
> > xmlReader.Close()
> > Dim r as Regex
> > dim element as string
> > dim output as string
> > For Each element in alWordList
> > r = New Regex("\b" & element)
> > InputString = r.Replace(InputString, "****")
> > Next
> > TextBox1.Text = InputString
> > If origtext <> TextBox1.Text Then
> > Label1.Text = "Funky words, please replace."
> > Else
> > Label1.Text = "Okay." 'This is just included for testing
> > End If
> > End Sub
> > Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > CheckString(TextBox1.Text)
> > End Sub
> > Any suggestions will be greatly appreciated!
> > --
> > Sandy
>
Thanks for your response!

Sandy

"DoesDotNet" wrote:

> You could achieve this by e.g. creating a new class with a static
> method called
> public static bool CheckString( string input, string censoredString )
> that returns a bool indicating whether it had to censor the string.
> The censored string is written into the second string reference you
> pass.
> Since I am not familiar with VB, here is the C# for that.
> public class SwearWordChecker{
> public static string CheckString( string input, string censoredString
> ){
> censoredString = input;
> // do your thing here
> ...
> censoredString = r.Replace(InputString, "****");
> ...
> //if they are the same, return true
> return (input == censoredString);
> }
> }
> and then use that class in your Button code:
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> string censored = null;
> if( !CheckString(TextBox1.Text, censored) ){
> TextBox1.Text = censored;
> lblError.Text = "You cursing sombitch."
> }
> End Sub
> Hope this helps.
> Manuel
>
> Sandy wrote:
> > Hello -
> > This code was snagged by me from the Internet and altered. Its
> purpose is
> > to check for swear words. It works the way it currently is, but I
> need it to
> > be more generic -- i.e., I don't want it to refer to TextBox1 or
> Label1
> > directly; I want to be able to plug in the name of any textbox into
> > CheckString(TextBox1.Text), instead of just a specific textbox. [I
> have many
> > textboxes on one page that all need to be checked.]
> > Public Sub CheckString(inputstring as string)
> > Dim alWordList as New ArrayList
> > Dim origtext as String
> > origtext = TextBox1.Text
> > dim xmlDocPath as string = server.mappath("bad_words2.xml")
> > dim xmlReader as XmlTextreader = New xmlTextReader(xmlDocPath)
> > While (xmlReader.Read())
> > if xmlReader.Nodetype=xmlNodeType.Text then
> > alWordList.Add(xmlReader.Value)
> > End If
> > End While
> > xmlReader.Close()
> > Dim r as Regex
> > dim element as string
> > dim output as string
> > For Each element in alWordList
> > r = New Regex("\b" & element)
> > InputString = r.Replace(InputString, "****")
> > Next
> > TextBox1.Text = InputString
> > If origtext <> TextBox1.Text Then
> > Label1.Text = "Funky words, please replace."
> > Else
> > Label1.Text = "Okay." 'This is just included for testing
> > End If
> > End Sub
> > Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > CheckString(TextBox1.Text)
> > End Sub
> > Any suggestions will be greatly appreciated!
> > --
> > Sandy
>

Please click the back button on your browser and

Hi All,

In my one project, at many aspx pages I am getting below error.
Could anyone please give me solution of this.
================
Please click the back button on your browser and try again.Session state is
not available in this context.
================
I really tried to solve this a lot but could not get the solution.

Thanking you in advance,
RahulSeems sessions are disabled for your application and being used everywhere
inside applications...

Sudhakar Sadasivuni
http://weblogs.asp.net/ssadasivuni
MyUG : http://www.mugh.net

"Rahul Borade" wrote:

> Hi All,
> In my one project, at many aspx pages I am getting below error.
> Could anyone please give me solution of this.
> ================
> Please click the back button on your browser and try again.Session state is
> not available in this context.
> ================
> I really tried to solve this a lot but could not get the solution.
> Thanking you in advance,
> Rahul
>
Hi,

Thanks for your immediate reply!

But, if I check session on other aspx pages, the session
state is perfectly available.

What could be any other possiblity for this ... can you
please tell me ...

>--Original Message--
>Seems sessions are disabled for your application and
being used everywhere
>inside applications...
>
>Sudhakar Sadasivuni
>http://weblogs.asp.net/ssadasivuni
>MyUG : http://www.mugh.net
>
>"Rahul Borade" wrote:
>> Hi All,
>>
>> In my one project, at many aspx pages I am getting
below error.
>> Could anyone please give me solution of this.
>> ================
>> Please click the back button on your browser and try
again.Session state is
>> not available in this context.
>> ================
>> I really tried to solve this a lot but could not get
the solution.
>>
>> Thanking you in advance,
>> Rahul
>>
>>
>>
>.

Please click the back button on your browser and

Hi All,
In my one project, at many aspx pages I am getting below error.
Could anyone please give me solution of this.
================
Please click the back button on your browser and try again.Session state is
not available in this context.
================
I really tried to solve this a lot but could not get the solution.
Thanking you in advance,
RahulSeems sessions are disabled for your application and being used everywhere
inside applications...
Sudhakar Sadasivuni
[url]http://weblogs.asp.net/sasivuni[/url]
MyUG : http://www.mugh.net
"Rahul Borade" wrote:

> Hi All,
> In my one project, at many aspx pages I am getting below error.
> Could anyone please give me solution of this.
> ================
> Please click the back button on your browser and try again.Session state i
s
> not available in this context.
> ================
> I really tried to solve this a lot but could not get the solution.
> Thanking you in advance,
> Rahul
>
>
Hi,
Thanks for your immediate reply!
But, if I check session on other aspx pages, the session
state is perfectly available.
What could be any other possiblity for this ... can you
please tell me ...

>--Original Message--
>Seems sessions are disabled for your application and
being used everywhere
>inside applications...
>
>Sudhakar Sadasivuni
>[url]http://weblogs.asp.net/sasivuni[/url]
>MyUG : http://www.mugh.net
>
>"Rahul Borade" wrote:
>
below error.
again.Session state is
the solution.
>.
>

please convert this classic asp to asp.net

would anyone be willing to convert this classic asp/vbscript/ado to asp.net/vb.net/ado.net? I want to learn how to set Session("userId") using the absolute simplest techniques in asp.net. Thanks in advance.


Dim myConnection
Dim myConnectionStr
Dim myRecordSet
Dim mySQL

Set myConnection = Server.CreateObject("ADODB.Connection")
myConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dataStores\webDbs\webLogin.mdb;"
myConnection.Open myConnectionStr

Set myRecordSet = Server.CreateObject("ADODB.RecordSet")
mySQL = "SELECT tblUsers.userId FROM tblUsers WHERE (((tblUsers.emailAddress)='test@dotnet.itags.org.yahoo.com'));"
myRecordSet.Open mySQL, myConnection

If Not myRecordSet.EOF Then
Session("userId") = myRecordSet("userId")
End If

myRecordSet.Close
Set myRecordSet = Nothing
myConnection.Close
Set myConnection = Nothing

NOTE: Moderator fixed <Code> tags...Hi,

instead of a recordset you can use asqldatareader instead.

Alsoview forum 132.

Grz, Kris.


Sub Page_Load(s As Object, e As EventArgs)
lblResult.Text = getUserId()
End Sub

Function getUserId() As String
Dim myConnection As OleDbConnection
Dim myConnectionStr As String
Dim myCommand As OleDbCommand
Dim myDataReader As OleDbDataReader
Dim mySQL As String

myConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Datastores\LCS_Web\BoardElect.mdb;"
myConnection = New OleDbConnection(myConnectionStr)

mySQL = "SELECT tblUsers.userId FROM tblUsers WHERE (((tblUsers.emailAddress)='test@.yahoo.com'));"
myCommand = New OleDbCommand(mySQL, myConnection)
myConnection.Open()
myDataReader = myCommand.ExecuteReader()

myDataReader.Read()
getUserId = myDataReader.GetValue(0)

myDataReader.Close()
myConnection.Close()
End Function

got it from another forum, but thanks
Does this help ?

PopUpWindow 1.1

regards
that's a very nice component you've written, but is there some correlation to the topic at hand?

Please correct this error

please correct this error while debugging

it show the message box like this when we start the debugging in dot net 2003
But IIS is working properly.if i go for debugging it give this error.

Actually i have loaded 2003 and 2005 in single operating system , but don't say remove 2005 it working properly.

"Error while trying to run project : Unable to start debugging on the web ser server"

Click Help for More Information

OK Help

Plz help me.......... i am unable work without debugging some times.
if any one know reply me

Thx in advance

Hi

you have <compilation debug="false" /> in we.config

change it to <compilation debug="true" />


Hi,

Check out my post on the same topic:

http://geekswithblogs.net/vivek/archive/2006/09/12/90930.aspx

HTH,

Vivek