Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All --

I really confused. I found an example using Microsoft.Samples.Alert and I open the Alert.aspx page provided and everything works fine.

When I import the dll into my project, copy the script code into my aspx page, it doesn't recognize the code and I also notice that in the aspx page provided, on the top left of page where you can pick from 'Client Objects & Events', it has Server Code and it shows the alerts I'm trying to create. I can't figure out what I'm missing.

Here is the code I'm copying into my aspx.page

XML
<%@ Register Namespace="Microsoft.Samples.Alert" TagPrefix="ms" Assembly="Alert" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
    public void ServerShow(object sender, EventArgs e)
    {
        ServerAlert.Show();
    }
    public void ServerAlertChoice(object sender, AlertChoiceEventArgs e)
    {
        AlertResult.Text = "You clicked " + e.Result.ToString();
        AlertResult.Visible = true;
    }
    public void ConfirmClick(object sender, EventArgs e) {
        ConfirmResult.Visible = true;
    }
</script>



I have the alert.dll & Alert.pdb in my bin directory and I added it using 'Add references/browse'

When I copy the exact same code, everything is underlined in blue and the errors are:

The name 'ServerAlert' does not exist in the current context
Microsoft.Samples.Alert.AlertResult does not contain a definition for Text
""" for Visible
etc.

What am I missing? It's got to be simple! I'm using Visual Web Developer 2008 Express

Thanks!
Posted
Updated 28-Jun-11 17:00pm
v2

1 solution

Are you sure you added the following code? The only reason I can see why it errored is because your compiler is referring to the AlertResult assembly rather than the label control which is supposed to be added, based on the sample code from ASP.Net blogsite.
<asp:Label ID="AlertResult" runat="server" ForeColor="Red" Visible="false" />

I used http://weblogs.asp.net/bleroy/archive/2005/12/01/432016.aspx[^] as a reference.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900