Search:
Namespaces
Discussions
.NET v1.1
Feedback
Script Problem
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.aspnet
.
Post a new message to this list...
Wayne Wengert
I am attempting to incorporate some techniques I found in an MSDN article
into one of my aspx pages. It basically adds a new class that Inherits from
the System.Web.UI.
Page
and includes some new subs and function (some are
shown below). I have a page based on that new class and in my code where a
user clicks on a Save button (saves data to my DB) I want to display an
alert message. I get the error indicated below when I run the page - I
assume it has to do with the onclick event which calls sub in the base
class? How should this be coded?
Wayne
============= Error Information ============
Compiler Error Message: BC30201: Expression expected.
Source Error:
Line 30: <asp:textbox id="txtMisc" style="Z-INDEX: 117; LEFT: 133px;
POSITION: absolute; TOP: 497px" runat="server"
Line 31: Width="475px" Height="56px" MaxLength="200"
TextMode="MultiLine" Rows="2"></asp:textbox>
Line 32: <asp:button id="btnSave" style="Z-INDEX: 118; LEFT: 159px;
POSITION: absolute; TOP: 564px" runat="server"
Line 33: Width="100px" Height="29px" onclick="DisplayAlert('The
information has been added to the database!')" Text="Save &
Exit"></asp:button>
Line 34: <asp:button id="btnCancel" style="Z-INDEX: 119; LEFT: 348px;
POSITION: absolute; TOP: 565px"
============= In Class Inherited ==============
Public Sub DisplayAlert(ByVal message As String)
RegisterClientScriptBlock(
Guid
.NewGuid().ToString(), _
"<script language=""JavaScript"">" & GetAlertScript(message) & "</script>")
End Sub
Public Function GetAlertScript(ByVal message As String) As String
Return "alert('" & message.Replace("'", "\'") & "');"
End Function
Reply to this message...
Karl
The OnClick method of the Button calls an
EventHandler
...try to modify your
code like so (i got rid of the style stuff just to help readability, you can
safely put it in)
<asp:button id="btnSave" runat="server" CommandArgument="'The information
has been added to the database" onclick="save_click" Text="Save" />
and the method:
Protected Sub Save_Click(ByVal sender As Object, ByVal e As EventArgs)
DisplayAlert(CType(sender, Button).CommandArgument)
End Sub
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Wayne Wengert" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Wayne Wengert
Thanks Karl. Let me experiment with that.
Wayne
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:
Click here to reveal e-mail address
...
> The OnClick method of the Button calls an
EventHandler
...try to modify
your
> code like so (i got rid of the style stuff just to help readability, you
can
[Original message clipped]
Reply to this message...
Wayne Wengert
I tried adding the code:
DisplayAlert("The information has been added to the database!")
in the btnSave_Click event but although I can verify that the code is being
executed the alert never shows?
Wayne
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:
Click here to reveal e-mail address
...
> The OnClick method of the Button calls an
EventHandler
...try to modify
your
> code like so (i got rid of the style stuff just to help readability, you
can
[Original message clipped]
Reply to this message...
Karl
That's odd, I tried it out and got it working before posting you the
solution.
Can you confirm that the javascript is being rendered on the page?
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Wayne Wengert" <
Click here to reveal e-mail address
> wrote in message
news:%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Wayne Wengert
Karl;
How can I confirm that? I did put in a breakpoint and I know the
DisplayAlert code is executed?
Wayne
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.EventArgs
System.EventHandler
System.Guid
System.Web.UI.Page
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com