locked
Database custom Message popup RRS feed

  • Question

  • User821936469 posted

    hey guyz,

    I am having an application in asp.net. I have an Master Page in it with save button in it. There are Add and Edit Form with some data entry fields in it.

    My requirement is that when i perform the Manual Input on Add form and click on the Save Button, the Custom message shall come from the database that the 'save operation of add'  and if the control is coming from Edit Form then Custom message shall be given that 'Save Operation of Edit' getting performed.

    How to create custom Message in My sql and then how to call it from Asp.net depending on the above condition.

    Thanks 

    SUSHANT2014!!!

    Tuesday, July 22, 2014 7:29 AM

Answers

  • User1428246847 posted
    1. Store your messages in a MySql table.
    2. Read message that you need from database table
    3. Add message to button

    I would create a table (let's say tblMessages) with three data columns for flexibility

    • webpage; contains the webpage (e.g. '/Default.aspx')
    • button; contains the button (e.g. 'btnAdd' or 'btnEdit')
    • message; the actual message

    You can pull the required message with something like

    select message from tblMessages where webpage ='/Default.aspx' and button = 'btnAdd'

    The below is one of your buttons

        <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
    

    Sample code with javascript pop-ups

    protected void Page_Load(object sender, EventArgs e)
    {

    // simulated message from your database; replace with code to read a message from database table string msg = "Saving"; // string with a javascript for a popup string script = String.Format("alert('{0}');", msg); // add to button's onClick btnAdd.Attributes.Add("onclick", script);

    // do similar for your other buttons
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
    // simulate a process
    System.Threading.Thread.Sleep(5000);

    // simulate a message from database; replace with code to read a message from database table
        string msg = "Saving completed";
    // string with a javascript for a popup
        string script = String.Format("alert('{0}');", msg);
    // launch popup
        ClientScript.RegisterStartupScript(GetType(), "CompletedScript", script, true);

    }

    Hope that this helps to get you on the way.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 24, 2014 8:32 AM

All replies

  • User821936469 posted

    Fellas waiting for your Reply

    Thursday, July 24, 2014 1:25 AM
  • User1428246847 posted
    1. Store your messages in a MySql table.
    2. Read message that you need from database table
    3. Add message to button

    I would create a table (let's say tblMessages) with three data columns for flexibility

    • webpage; contains the webpage (e.g. '/Default.aspx')
    • button; contains the button (e.g. 'btnAdd' or 'btnEdit')
    • message; the actual message

    You can pull the required message with something like

    select message from tblMessages where webpage ='/Default.aspx' and button = 'btnAdd'

    The below is one of your buttons

        <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
    

    Sample code with javascript pop-ups

    protected void Page_Load(object sender, EventArgs e)
    {

    // simulated message from your database; replace with code to read a message from database table string msg = "Saving"; // string with a javascript for a popup string script = String.Format("alert('{0}');", msg); // add to button's onClick btnAdd.Attributes.Add("onclick", script);

    // do similar for your other buttons
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
    // simulate a process
    System.Threading.Thread.Sleep(5000);

    // simulate a message from database; replace with code to read a message from database table
        string msg = "Saving completed";
    // string with a javascript for a popup
        string script = String.Format("alert('{0}');", msg);
    // launch popup
        ClientScript.RegisterStartupScript(GetType(), "CompletedScript", script, true);

    }

    Hope that this helps to get you on the way.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 24, 2014 8:32 AM