How to show popup message in a webform

Discussion in 'ASP .Net' started by Ipsita, Nov 13, 2004.

  1. Ipsita

    Ipsita Guest

    Hi,

    I am explaining the scenario of what I am trying to do:
    - I have a webform with some controls, from which I am taking the
    data. eg say Username, password
    - I am passing these data as parameters to the web service method
    result = serviceproxy.VerifyUser(username, password) on the event of
    the "Submit" button_click.
    - The webservice webmethod uses the username, password to verify if
    the user is valid user. If no, it sends an error message to the client
    say "Invalid Username" which gets stored in the variable "result" as
    shown above.
    - I need to show this message stored in variable "result" in a popup
    box on the client side. And when the user clicks "OK" on the popup box
    he can continue further.

    In my button_Click method I am doing the following:
    string strScript, result;
    Client.proxy serviceproxy = new Client.proxy();
    result = serviceproxy.VerifyUser(username, password) ;
    strScript = "<script language=JavaScript>alert('" & result &
    "')</script>";

    I am stuck now..I dont know what exactly to do. Do I need to add
    something to the html file?

    Can anyone tell me the way to do this? Please let me know.

    Thanks and Regards
    Ipsita
     
    Ipsita, Nov 13, 2004
    #1
    1. Advertising

  2. Your button click is a server side event, so the output of this needs to be
    an alert actioned in the onload of the resulting page.

    --
    Regards

    John Timney
    ASP.NET MVP

    "Ipsita" <> wrote in message
    news:...
    > Hi,
    >
    > I am explaining the scenario of what I am trying to do:
    > - I have a webform with some controls, from which I am taking the
    > data. eg say Username, password
    > - I am passing these data as parameters to the web service method
    > result = serviceproxy.VerifyUser(username, password) on the event of
    > the "Submit" button_click.
    > - The webservice webmethod uses the username, password to verify if
    > the user is valid user. If no, it sends an error message to the client
    > say "Invalid Username" which gets stored in the variable "result" as
    > shown above.
    > - I need to show this message stored in variable "result" in a popup
    > box on the client side. And when the user clicks "OK" on the popup box
    > he can continue further.
    >
    > In my button_Click method I am doing the following:
    > string strScript, result;
    > Client.proxy serviceproxy = new Client.proxy();
    > result = serviceproxy.VerifyUser(username, password) ;
    > strScript = "<script language=JavaScript>alert('" & result &
    > "')</script>";
    >
    > I am stuck now..I dont know what exactly to do. Do I need to add
    > something to the html file?
    >
    > Can anyone tell me the way to do this? Please let me know.
    >
    > Thanks and Regards
    > Ipsita
     
    John Timney \(ASP.NET MVP\), Nov 13, 2004
    #2
    1. Advertising

  3. Ipsita

    Ipsita Guest

    Hi!

    I was able to show a message as an alert. On the client side I used:
    Label1.Text = "<script language=JavaScript>alert('Hello');</script>";

    The value 'Hello' shows in the pop up alert.

    Next phase of the problem is that instead of showing a fixed message
    ie 'Hello' in the alert, if I wanted to show the contents of a string
    variable, how do I do it?
    eg string strMessage = "Excellent";
    Label1.Text = "<script language=JavaScript>alert('" & strMessage &
    "');</script>"; ----------> this shows compilation error

    Please let me know how to show the value of the variable in the pop
    up. I am using webform and C# in ASP.NET.

    Thanks and Regards
    Ipsita

    "John Timney \(ASP.NET MVP\)" <> wrote in message news:<>...
    > Your button click is a server side event, so the output of this needs to be
    > an alert actioned in the onload of the resulting page.
    >
    > --
    > Regards
    >
    > John Timney
    > ASP.NET MVP
    >
    > "Ipsita" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I am explaining the scenario of what I am trying to do:
    > > - I have a webform with some controls, from which I am taking the
    > > data. eg say Username, password
    > > - I am passing these data as parameters to the web service method
    > > result = serviceproxy.VerifyUser(username, password) on the event of
    > > the "Submit" button_click.
    > > - The webservice webmethod uses the username, password to verify if
    > > the user is valid user. If no, it sends an error message to the client
    > > say "Invalid Username" which gets stored in the variable "result" as
    > > shown above.
    > > - I need to show this message stored in variable "result" in a popup
    > > box on the client side. And when the user clicks "OK" on the popup box
    > > he can continue further.
    > >
    > > In my button_Click method I am doing the following:
    > > string strScript, result;
    > > Client.proxy serviceproxy = new Client.proxy();
    > > result = serviceproxy.VerifyUser(username, password) ;
    > > strScript = "<script language=JavaScript>alert('" & result &
    > > "')</script>";
    > >
    > > I am stuck now..I dont know what exactly to do. Do I need to add
    > > something to the html file?
    > >
    > > Can anyone tell me the way to do this? Please let me know.
    > >
    > > Thanks and Regards
    > > Ipsita
     
    Ipsita, Nov 15, 2004
    #3
  4. Ipsita

    John M Deal Guest

    What I think you may be looking for is the following (watch out for word
    wrap):

    string message = "Excellent!";
    Page.RegisterStartupScript("LogonResults", "<script
    language=JavaScript>alert('" + message + "');</script>");

    The compilation error you would have gotten with your example below is
    that & is a concatenation character in VB/VB.Net but not in C#. You
    would need to use the + sign.

    There are many Register type methods for the Page object that can be
    used to send script to the client, so this may not be the one you want
    but it will show the message box as soon as the page loads.

    If you were to apply this to your original code block you would get
    (again watch for word wrap):

    string strScript, result;
    Client.proxy serviceproxy = new Client.proxy();
    result = serviceproxy.VerifyUser(username, password) ;
    strScript = "<script language=JavaScript>alert('" + result + "')</script>";
    Page.RegisterStartupScript("LogonResults", strScript);

    Hope that helps.

    Have A Better One!

    John M Deal, MCP
    Necessity Software


    Ipsita wrote:
    > Hi!
    >
    > I was able to show a message as an alert. On the client side I used:
    > Label1.Text = "<script language=JavaScript>alert('Hello');</script>";
    >
    > The value 'Hello' shows in the pop up alert.
    >
    > Next phase of the problem is that instead of showing a fixed message
    > ie 'Hello' in the alert, if I wanted to show the contents of a string
    > variable, how do I do it?
    > eg string strMessage = "Excellent";
    > Label1.Text = "<script language=JavaScript>alert('" & strMessage &
    > "');</script>"; ----------> this shows compilation error
    >
    > Please let me know how to show the value of the variable in the pop
    > up. I am using webform and C# in ASP.NET.
    >
    > Thanks and Regards
    > Ipsita
    >
    > "John Timney \(ASP.NET MVP\)" <> wrote in message news:<>...
    >
    >>Your button click is a server side event, so the output of this needs to be
    >>an alert actioned in the onload of the resulting page.
    >>
    >>--
    >>Regards
    >>
    >>John Timney
    >>ASP.NET MVP
    >>
    >>"Ipsita" <> wrote in message
    >>news:...
    >>
    >>>Hi,
    >>>
    >>>I am explaining the scenario of what I am trying to do:
    >>>- I have a webform with some controls, from which I am taking the
    >>>data. eg say Username, password
    >>>- I am passing these data as parameters to the web service method
    >>>result = serviceproxy.VerifyUser(username, password) on the event of
    >>>the "Submit" button_click.
    >>>- The webservice webmethod uses the username, password to verify if
    >>>the user is valid user. If no, it sends an error message to the client
    >>>say "Invalid Username" which gets stored in the variable "result" as
    >>>shown above.
    >>>- I need to show this message stored in variable "result" in a popup
    >>>box on the client side. And when the user clicks "OK" on the popup box
    >>>he can continue further.
    >>>
    >>>In my button_Click method I am doing the following:
    >>>string strScript, result;
    >>>Client.proxy serviceproxy = new Client.proxy();
    >>>result = serviceproxy.VerifyUser(username, password) ;
    >>>strScript = "<script language=JavaScript>alert('" & result &
    >>>"')</script>";
    >>>
    >>>I am stuck now..I dont know what exactly to do. Do I need to add
    >>>something to the html file?
    >>>
    >>>Can anyone tell me the way to do this? Please let me know.
    >>>
    >>>Thanks and Regards
    >>>Ipsita
     
    John M Deal, Nov 15, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. titof
    Replies:
    0
    Views:
    546
    titof
    Jul 24, 2003
  2. timmso
    Replies:
    1
    Views:
    542
    Alex Papadimoulis
    Dec 12, 2003
  3. =?Utf-8?B?Vk1J?=

    Moving value from popup Webform to main Webform?

    =?Utf-8?B?Vk1J?=, Oct 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    607
    GroupReader
    Oct 9, 2006
  4. Ipsita

    How to show popup message in a webform

    Ipsita, Nov 13, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    170
    Derek Harmon
    Nov 15, 2004
  5. Jens Peter Hansen
    Replies:
    7
    Views:
    578
    Randy Webb
    Jun 19, 2004
Loading...

Share This Page