Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem on return Confirm

Status
Not open for further replies.

vilrbn

Programmer
Oct 29, 2002
105
FR
Hello,

I'm using ASP.NET with VB.
I'm filling a datagrid with image files. In case one file is already located on the server, I want to send a confirm message. This message warns the user that the file will be replaced if OK is selected. Otherwise I'm doing nothing.

I have an hidden text field that containins the confirm return value. I'm also using the OnServerChange event to catch this value through my VB code. But the event does not fire when the hidden field value is changed. It's fired next time I click on the cmdUpload submit button.

Here's my code:

Protected WithEvents hidden1 As System.Web.UI.HtmlControls.HtmlInputHidden

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hidden1.EnableViewState = True
End Sub

Public Sub Add_Image(ByVal sender As System.Object, ByVal e As System.EventArgs)

Select Case Exist
Case True
'if the file already exists, pop up a warning message
lblMsg.Text = &quot;<SCRIPT language = 'javascript'>a = confirm('This file already exists');document.Form1.hidden1.value=a;</SCRIPT>&quot;
...
End Sub

Public Sub hidden1_ServerChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hidden1.ServerChange

End Sub


<asp:button id=&quot;cmdUpload&quot; onclick=&quot;Add_Image&quot; runat=&quot;server&quot; Text=&quot;Add...&quot;>

<input id=&quot;hidden1&quot; type=&quot;hidden&quot; name =&quot;hidden1&quot; runat=&quot;server&quot; onchange =&quot;test();&quot; onserverchange =&quot;hidden1_ServerChange&quot;>

How can I get back the confirm user choice within my VB code ?
 
you can either do it client-side... or set autopostback to true on the textbox...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top