Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

confirm in asp.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Betina Andersen - 30 Oct 2007 12:33 GMT
Hi

I am using vb in asp.net and I need to have a confirm in the middle of my
code(code-behind), but cannot get the confirm to display when I want it, but
it comes when my button has ended it code, any help appriciated.

Sub Button_Click
<code>
.
.
Dim scriptString As New StringBuilder
scriptString.Append("<script language='javascript' type='text/javascript'>")
scriptString.Append("var ok=confirm('Budget findes i forvejen - Ønskes det
overskrevet?\n" & strIkkeKopieret & "');" & "document.getElementById('" &
Skjult.ClientID & "').value=ok;")
scriptString.Append("</")
scriptString.Append("script>")
ScriptManager.RegisterStartupScript(sender, Me.GetType, "Info",
scriptString.ToString, False)
.
.
<mere kode>
End Sub

Then the box shows here and not where I definded it to? I tries both the
ScriptManager.RegisterStartupScript and
theScriptManager.RegisterClienScriptBlock, I am using Ajax, so it has to be
ScriptManager I have to use, as I understand it.

Regards Betina
Patrice - 30 Oct 2007 13:02 GMT
You just can't. The programming model is :
- you create an HTML page using server side code
- this HTML pages is rendered by the browser and its client side code (if
any) runs either directly on depending on which client side events are
happening
- eventually this page postback to runs some other server side code
etc...

Usually what you are trying to do is done by asking the question client side
when the button is clicked. You can then cancel the event (and nothing else
happens) or confirm (and then it usually results in a postback where you can
run the server side code that will do the job).

As a side note you may want to try a more focused group such as
microsoft.public.framework.aspnet as this is more an ASP.NET issue than a
specific language issue.

--
Patrice

> Hi
>
[quoted text clipped - 27 lines]
>
> Regards Betina
Cor Ligthert[MVP] - 31 Oct 2007 06:36 GMT
Betina,

As Patrice tells you, you can run on the serverside everything that you want
to do on a page. However you cannot start a process yourself direct on the
clientside, that is something the client has to do and a lot for that is
prevented in the webbrowsers.

(That is exactly the reason that we get so much security updates, because
some people want to do that).

Cor
Betina Andersen - 31 Oct 2007 08:27 GMT
So what you are saying, it is not possible to aks the user a yes/no question
in the middle of some code and act accordingly to the reply?

Regards Betina

> Betina,
>
[quoted text clipped - 7 lines]
>
> Cor
Patrice - 31 Oct 2007 09:45 GMT
Not in the *middle* of server side code.

The flow should be :
- the user enters the data and press the submit button
- server side code runs and send to the client the client side markup and/or
code that will ask the question to the user (at this point there are nothing
going on server side)
- client side the user answers to the question and press a submit button
- server side code runs etc...

You have to split your server side code in two parts :
- a part that renders the client side dialog
- a part that will be triggered when the client side dialog is answered

A web application is always based on the same principle :
- server side codes runs (and ends)
- the user interact with the markup sent by the server side code and at some
point trigger some server side code going back to step 1

You can't mix server side and client side interaction within the same round
trip

--
Patrice

> So what you are saying, it is not possible to aks the user a yes/no
> question in the middle of some code and act accordingly to the reply?
[quoted text clipped - 12 lines]
>>
>> Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.