Message box in asp.net

Discussion in 'ASP .Net' started by ratnakarp@gmail.com, Mar 10, 2006.

  1. Guest

    hi,

    i want to pop up a message box when a button is clicked. the situation
    is something like this as follows.


    protected void button1_click(.. , ..)
    {
    .......
    ........
    .......

    response.write(<script language="javascript"> or
    language="vbscript">confirm or msgbox or etc..</script>)
    if(clicked yes)
    {
    do the following

    }
    else
    get out of the method

    }


    is there any way if user clicks yes on the confirm box or message box,
    the rest of the code in button1 click method should be executed
    otherwise get out of the method. Any help or reference is appreciated.

    Thanks,
    Ratnakar Pedagani
     
    , Mar 10, 2006
    #1
    1. Advertising

  2. btn.Attributes.Add("onClick", "return confirm('Do you really want to delete
    the record?');");

    HTH

    Elton Wang

    "" wrote:

    > hi,
    >
    > i want to pop up a message box when a button is clicked. the situation
    > is something like this as follows.
    >
    >
    > protected void button1_click(.. , ..)
    > {
    > .......
    > ........
    > .......
    >
    > response.write(<script language="javascript"> or
    > language="vbscript">confirm or msgbox or etc..</script>)
    > if(clicked yes)
    > {
    > do the following
    >
    > }
    > else
    > get out of the method
    >
    > }
    >
    >
    > is there any way if user clicks yes on the confirm box or message box,
    > the rest of the code in button1 click method should be executed
    > otherwise get out of the method. Any help or reference is appreciated.
    >
    > Thanks,
    > Ratnakar Pedagani
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Mar 10, 2006
    #2
    1. Advertising

  3. Guest

    Hello Elton,

    Thanks for your reply, but here i'm facing the problem., i forgot to
    add a condition. i changed the code. In the following code, if the
    cond1 is true, then the confirm message should pop up. if clicked yes,
    i should be able to do something else within button click method. for
    example

    protected void button1_click(.. , ..)
    {
    x=callmethod1();
    y=callmethod2();
    z=str1;

    if(z>40)
    {
    //pop up confirm box, "do you want to continue"
    response.write(<script language="javascript"> or
    language="vbscript">confirm or msgbox or etc..</script>)
    if(clicked yes)
    {
    save the details in the database;
    }
    else
    {
    get out of the method
    }
    }

    can you please let me know how to proceed further. Kindly let me know
    if you need to know anything else.

    Thanks & Regards,
    Ratnakar Pedagani.
     
    , Mar 10, 2006
    #3
  4. You should know that client-server (Web) application is different from
    desktop one. Especially, in server-side code you can’t directly interact with
    user. What I can suggest is to put your logic on client-side (javascript
    function(s)). Only when postback, on server-side to save detail to DB:

    Server Code:
    Page_Load(){
    // ...
    btn.Attributes.Add("onClick", "return CheckZ();");
    }

    btn_Click(...)
    {
    // save info;
    }

    Client code:

    <script>
    function CheckZ()
    {
    var z = getZ;
    if(z <=40)
    {
    return false;
    }
    Return confirm(confirm message);
    }
    </script>


    HTH


    "" wrote:

    > Hello Elton,
    >
    > Thanks for your reply, but here i'm facing the problem., i forgot to
    > add a condition. i changed the code. In the following code, if the
    > cond1 is true, then the confirm message should pop up. if clicked yes,
    > i should be able to do something else within button click method. for
    > example
    >
    > protected void button1_click(.. , ..)
    > {
    > x=callmethod1();
    > y=callmethod2();
    > z=str1;
    >
    > if(z>40)
    > {
    > //pop up confirm box, "do you want to continue"
    > response.write(<script language="javascript"> or
    > language="vbscript">confirm or msgbox or etc..</script>)
    > if(clicked yes)
    > {
    > save the details in the database;
    > }
    > else
    > {
    > get out of the method
    > }
    > }
    >
    > can you please let me know how to proceed further. Kindly let me know
    > if you need to know anything else.
    >
    > Thanks & Regards,
    > Ratnakar Pedagani.
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Mar 10, 2006
    #4
  5. blackstaronline.net, Mar 10, 2006
    #5
  6. Guest

    Do you guyz got any other ideaz, looks like these things are not
    working for me? Thanks for your help

    Regards,
    Ratnakar Pedagani
     
    , Mar 13, 2006
    #6
    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. Padam Jain
    Replies:
    1
    Views:
    1,276
    Anatoly
    Jul 14, 2003
  2. Ernesto Salas

    asp. net and message box???

    Ernesto Salas, Nov 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    491
    Scott M.
    Nov 27, 2003
  3. kai
    Replies:
    7
    Views:
    4,966
  4. Gnarlodious
    Replies:
    4
    Views:
    17,642
    elizas
    May 5, 2010
  5. bienwell
    Replies:
    5
    Views:
    5,222
    bienwell
    Aug 13, 2006
Loading...

Share This Page