Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Autopostback

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-05-18 : 13:02:33
I am new at vb.net. I know this is SQL forum, but still maybe someone can have any idea

I have a input type = file that gives me browse button and text box for choosing files. And I have dropdown box that needs to be set to autopostback to true, but everytime autopostback happens it clears the textbox beside the browse button. Is there anyway to keep the value of the text box even though dropdown value changes?

<edit> Moved to .Net Forum </edit>

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-05-18 : 13:20:56
This is a security setting in most browsers and I don't think it can be changed.

Also using AutoPostBack to true is an accessibility problem to people who only use the keyboard. To fix this put a button next to the drop down list that they can click to post back the page.

Dustin Michaels
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-05-18 : 13:26:01
Your suggestion is good but I have actually two dropdown list and when first one fires , second one fills accordingly, so I do need a set autopostback to true for the first one, then of course my input type = file which is text box and browse button value gets clear..
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-05-18 : 15:06:45
You need an if condition in the page load event...


If Not IsPostBack Then...
else...
end if





Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-05-18 : 16:18:01
I have this
If IsPostBack = True Then Exit Sub
is this correct
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-05-18 : 18:51:07
quote:
Originally posted by notsosuper

I have this
If IsPostBack = True Then Exit Sub
is this correct



I dunno, I don't know your business you tell me if you want your app to just exit when you are at a postback?




Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

bmains
Starting Member

27 Posts

Posted - 2005-05-19 : 09:25:03
Your <input type="file">, did you add runat="server" attribute to it? ViewState should retain the value if runat="server" is declared...
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-05-19 : 09:40:27
If you try to set the value of a runat server file control then a .NET exception is thrown. This is not allowed because if it was then people could hide file uploader boxes with CSS and download files off peoples machines without them knowing. Also you don't need to have viewstate turned on to keep values from TextBoxes and DropDownLists when the page posts back. This is done thru the Request.Form collection object in ASP.NET

Dustin Michaels
Go to Top of Page

bmains
Starting Member

27 Posts

Posted - 2005-05-19 : 12:55:32
Yes, but turning off viewstate in this situation would require much more extra work because of the two data-bound dropdownlists. In this situation, viewstate would be the best option. In addition, runat="server" should work; I've used it in my applications; in fact, there will be a server control in the 2.0 framework.
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2005-05-20 : 08:42:54
Actually, I dont know why you would need to retain the file name in the File upload control. If the form is submitted, the file will be uploaded with it, and you will have access to the actual file on the server. You could save the file, and probably display a link to the it when the page reloads. And if the user chooses to upload another file, you could just replace it with the new one.

OS
Go to Top of Page
   

- Advertisement -