webForumDet fria alternativet

MsgBox från CodeBehind

5 svar · 456 visningar · startad av tihi

tihiMedlem sedan maj 200235 inlägg
#1

Jag har en sida med en massa textboxar och dropdownlist, dessa värden lagrar jag i en databas. Efter att lagringen gjorts vill jag visa en MsgBox som talar om hur lagringen gick. Men HUR gör jag detta? har försökt att lägga dem i CodeBehind sidan men får felmeddelande ->

It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Koden är ->
If ok Then
MsgBox("Dokumentet är lagrat", OKOnly.Information)
Else
MsgBox("Något blev fel vid lagring", OKOnly.Critical)
End If

Har även försökt att lägga det på aspx-sidan genom att tilldela en hidden variabels value ett värde och sen gjort en if sats liknande den ovan men det funkar inte heller...

Hoppas att nån kan hjälpa mig!!
Det borde väl fungera att göra det i VB istället för i typ JavaScript?!?

NETworkMedlem sedan juni 20011 732 inlägg
#2

Jag har ingen lösning på just ditt problem på rak arm, men jag brukar kasta upp ett javascript så här:

Page.RegisterClientScriptBlock("stringscript", "
<script language='javascript'>
alert('MEDDELANDE');
</script>
");
DinoMedlem sedan sep. 20011 914 inlägg
#3

Dokumentationen skrev:

The MsgBox function requires UIPermission at the SafeTopLevelWindows level, which may affect its execution in partial trust situations. For more information, see Requesting Permissions and UIPermission Class.

Det är inte så att msgbox är till för winforms.

tihiMedlem sedan maj 200235 inlägg
#4

Tack för svar, jag löste det med hjälp av VBscript i alla fall!

cyprysMedlem sedan dec. 20003 563 inlägg
#5

Hurdå om man får fråga?

tihiMedlem sedan maj 200235 inlägg
#6

På CodeBehind sidan sätter jag en hiddenvariabel = True/False beroende på hur lagringen gick.

If ok Then
hdOK.Value = True
Else
hdOK.Value = False
End If

Detta kollar jag sen på aspx-sidan.

if frmLagra.hdOk.value <> "" then
if frmLagra.hdOk.value = "True" then
MsgBox "Dokumentet är lagrat",64+0,"Dokumentet lagrat"
else
MsgBox "Det har inträffat ett fel."
end if
end if

137 ms totalt · 3 externa anrop · v20260731065814-full.3ab8d573
133 ms — hämta forumlista (db)
0 ms — hämta statistik (cache)
127 ms — hämta tråd, inlägg och bilagor (db)