Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I am creating a website in c# asp.net. I have a databound text box that is supposed to refresh according to a variable which gets changed. The textbox will change to the correct value when a link is clicked passing the variable, however when the variable is changed in a dropdown list all of the information on the change updates except for the text box. Is there some kind of refresh or something that I need to do? I do not understand why it changes with a link but not with a dropdown selection.
Posted
What do you mean by "all of the information"? Do you have other controls that is bound? Can you give a more detail description of your problem? Such as what is your text box bound to, what is the link that is clicked, what is the behavior of your dropdownlist, etc. I believe you know that binding mechanism in windows application and in web application is similar but not identical.
Amir Syafrudin
Posted

Yes there are other labels that get updated from a specific variable. The textbox is supopsed to get updated as well and does when the variable is changed in the url from a dynamic link, but when the same variable is changed from a drop down, then all the other labels get updated except for the textbox.

Its like the textbox will not refresh unless refreshed by the url.

Posted

Are you using a dataset as your general datasource? What method did you use to bind those controls? If you use simple binding, have you called the DataBind() method of each controls? Your dropdownlist triggers a postback right? Have you debug the event handler for your dropdownlist?

 

I can see your problem exist in updating that textbox. But with your explanation I don't think I can give any specific information. Sorry.

Amir Syafrudin
Posted

The textbox is getting updated by a method call to a database which gets a string. It tuns out that if I drag a textbox onto the screen from the asp toolbox and set the visibility to false, I can add this textbox when needed and it will update correctly. Previously, the textbox was created dynamically as part of the class above the page load.

 

It makes no sense to me why visual studio treats a textbox created statically in the asp page differently than one create in the aspx.cs file. Is there any known difference between the two. The only property that the text box created from the toolbox has that the one we were creating was the run="server" property.

 

Weird huh?

Posted

I'm still guessing here. But I kinda get a grip of your situation.

 

The runat="server" attribute is necessary so that your textbox can be accessed from codebehind (the "aspx.cs") file. It is a necessary means to communicate between the "aspx" file and the "aspx.cs" file.

 

When you create your textbox programmatically, it will not generate error when updated since it is a valid object. But doing that means you're only manipulating the textbox without communication with the "aspx" file. That way you won't see the changes when running your application.

 

I've always generate any widget using the toolbox in the design view. That way I'm certain that any modification to the widget programmatically will be shown correctly on the interface.

 

Hope that helps.

Amir Syafrudin
Posted

thanks for the replies Amir.. I think you are dead on to my problem now... This does, however bring up an issue. The boxes that we create need to be created dynamically according to how many are needed.. It would be really poor programming for us to just drag 10 or so on the screen and use as necissary.. What if for some reason a user requested 11... There has to be some way around this issue.. The textbox is holding information from the previous page and not refreshing unless a complete redirect occurs.. we even try creating a new one before assinging the new text to it.. we also even response.write the contents of the text box and it shows the correct string on top of the page but not in the box!?

 

So I guess we will just hack through that part for now, but there has be some kind of resolution for this...

 

Thanks for your help so far!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...