Hello there!

This is my firts post, and I'm happy of finding a site like this.

I have a little trouble with .net. I'm programming a site (i mean webforms) and something very weird happens.

If I have two webforms, both of them connects to a DB and they use the info from that DB to fill some combos and listboxes...

Imagine that I have a webform to register clients and another one to register client's type.

So, if a get to client's type and register, there's a listbox on the top of the webform that has to be reloaded. I can do a trick there and clear the listbox and make a sql statement to fill it again with the new info.

In fact, the Page_load procedure does the same thing when the webform starts. (I mean fills the listbox with the info registered already)

The problem comes when I use the other webform, I do something and return the webform I was using before. The info in the listbox is OLD. I tried to debbug there and... what was my surprisse???? The webform skips the Page_Load procedure!!! (At least if I don't type the F5 key to reload)

I REALLY NEED THAT THIS THING DOESN'T HAPPEN... because the users that are going to use this, don't know F5 key.

I friend said that I must enable the sesion state and the view state for this...

What do you suggest... I REALLY NEED HELP

OK, You need to relax, and give me a step by step approach to how your application is to work. What will the user be doing? Provide the sequence of events... i.e. 1. user logins in, 2. user clicks main menu, etc. Remember!!! I am not working on your application, so I do not know its functionality. Provide code where applicable as well..

Saying that, here is some information you may find useful.

1. From what you have said, the second webform is not being populated with the updated data. Requiring the REFRESH to be initiated. There is a reason for this: ASP.Net "caches" the server requests, so unless you call that request to the server again (implicitly) you will not get the updated cache. This is the whole principle of the .net environment, inorder to reduce calls to the DB/server. The Page_Load event only gets called on an initial load (first time to the page) or a Refresh (F5), never in a back/forward button control on the browser (that is the cached page).

2. You can get around this by how you code your application. It sounds like you have your code for specific actions in the wrong spot, or not called at the appropriate time. You have to consider logic when programming, and evaluate the functionality you want to provide and code based on variations from that. Remember, your user will never do what you expect them to.

3. The code in your Page_Load event should probably exist as a seperate function that you can call as needed. But without seeing the code first hand, I can only guess. Logic of your code!

I hope this helps in some way, I will check back regularily to see if you reply, as you sound stressed and I would like to help you out on this.

Good luck!

Hello there!

This is my firts post, and I'm happy of finding a site like this.

I have a little trouble with .net. I'm programming a site (i mean webforms) and something very weird happens.

If I have two webforms, both of them connects to a DB and they use the info from that DB to fill some combos and listboxes...

Imagine that I have a webform to register clients and another one to register client's type.

So, if a get to client's type and register, there's a listbox on the top of the webform that has to be reloaded. I can do a trick there and clear the listbox and make a sql statement to fill it again with the new info.

In fact, the Page_load procedure does the same thing when the webform starts. (I mean fills the listbox with the info registered already)

The problem comes when I use the other webform, I do something and return the webform I was using before. The info in the listbox is OLD. I tried to debbug there and... what was my surprisse???? The webform skips the Page_Load procedure!!! (At least if I don't type the F5 key to reload)

I REALLY NEED THAT THIS THING DOESN'T HAPPEN... because the users that are going to use this, don't know F5 key.

I friend said that I must enable the sesion state and the view state for this...

What do you suggest... I REALLY NEED HELP

Hello there! (I love Obi-Wan... that's why a say hi this way )

Did I show that stressed??? Oh my!!! I thought it was me! Anyway...

First that everything, thank's for replying... second... I have just 4 months into the .net world!!! So... although I've been programming like a monkey for the past few weeks, I didn't know what to do when this thing presented before me.

Ok, let's try to explain. Imagine a webform called client's type, with a listbox in the top, a "new" button, and textfields to fill above, a "Save" button and "Cancel" button. Get the picture? Alright!

When the webform loads, the listbox is filled with all the client's types recorded in the DB. You can see "Type 1", "Type 2", "Type 3" ok???

Well, you hit the "new" button, all the textfields are ready for a new type, you make a "Type 3" type and click on the "Save" button.

My "save" button is a private void (I'm programming in c#) and you call the DB make the insert and I make a trick right bellow my insert (in the same button procedure): clearing the listbox on top and fill it with the new information from the DB (a select from where statement and everything else).

OK. The info is in the DB. I have a menu at the side. There an option called Client. I move the webform... and it must fill a listbox on top, very similar to the other... and a dropdownlist with the client's types. Let's think I make a new client with this "type 3" type.

I use the menu to move to the client's type webform and SURPRISE!!! The info is old. I figured that the Page_load procedure is skiped this second time. I guess you are right. This is something like using the "Back" button from the explorer, but from my menu.

Is there a way to ensure that the webform ALWAYS get loaded????

Ask me if you don't understand something... I really need help. I hope you can get the picture. REMEMBER: I'm new in this world, so, my programming style is simple, there's something I'm missing because my lack of experience. Believe me! I work as logical as I can.

Thank's

OK, fabulous..... makes way more sense.

Ok, what is the command you are using from the menu to the client type webform? Response.Redirect? Or something else?

What you could do is change that to a Response.Redrirect ("ClientType.aspx") and this will call the Page_load event. But there are other methods.

Whatever code you have in the page_load event needs to be called when you select the selection form the menu.....inorder to update the Listbox.

One other thing. When you click save on that client type form, it should call the page_load event to refresh the display, and that should also refresh the contents of the list box. Much more elegant.

Hope this helps.

Hello there! (I love Obi-Wan... that's why a say hi this way )

Did I show that stressed??? Oh my!!! I thought it was me! Anyway...

First that everything, thank's for replying... second... I have just 4 months into the .net world!!! So... although I've been programming like a monkey for the past few weeks, I didn't know what to do when this thing presented before me.

Ok, let's try to explain. Imagine a webform called client's type, with a listbox in the top, a "new" button, and textfields to fill above, a "Save" button and "Cancel" button. Get the picture? Alright!

When the webform loads, the listbox is filled with all the client's types recorded in the DB. You can see "Type 1", "Type 2", "Type 3" ok???

Well, you hit the "new" button, all the textfields are ready for a new type, you make a "Type 3" type and click on the "Save" button.

My "save" button is a private void (I'm programming in c#) and you call the DB make the insert and I make a trick right bellow my insert (in the same button procedure): clearing the listbox on top and fill it with the new information from the DB (a select from where statement and everything else).

OK. The info is in the DB. I have a menu at the side. There an option called Client. I move the webform... and it must fill a listbox on top, very similar to the other... and a dropdownlist with the client's types. Let's think I make a new client with this "type 3" type.

I use the menu to move to the client's type webform and SURPRISE!!! The info is old. I figured that the Page_load procedure is skiped this second time. I guess you are right. This is something like using the "Back" button from the explorer, but from my menu.

Is there a way to ensure that the webform ALWAYS get loaded????

Ask me if you don't understand something... I really need help. I hope you can get the picture. REMEMBER: I'm new in this world, so, my programming style is simple, there's something I'm missing because my lack of experience. Believe me! I work as logical as I can.

Thank's

Hello there!

Nothing yet. Same thing, like a "Back" button.

Well I'm using a OPEN because I'm using a menu called obout easy menu (did you hear about it?)

You must use it in the code behind... something like:

<COMPONENTS>
<oem:MenuSeparator id="menuSeparator2" InnerHtml="">Proyectos</oem:MenuSeparator>
<oem:MenuItem id="vis" InnerHtml="MNT Proyectos" OnClientClick="open('ClientType.aspx','_self');"></oem:MenuItem>
</COMPONENTS>

BUT: I can't change it for a response.redirect.

I guess what it's happening to me shouldn't happen, isn't it? I will try to use a script to do the response.redirect.

My Project Manager tells me that I must use session params (well written?) because he says that I must take the state of the webform, send it to the server and call it back (????).

What do you say.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.