Server side functionality

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Server side functionality

    Hi All,

    I have an html button on .aspx page.

    <INPUT class="sbttn" id="btnComplete0" onclick="onComplete
    ()" type="button" value="Mark Completed"
    name="btnComplete0">

    When the user clicks on the html button the OnComplete
    function is called.

    <script language="javascript">
    function onComplete()
    {

    // Client side code

    // Clicking the server control via code
    WorkItemForm.btnComplete.click();

    }
    </script>


    I need to perform some server side functinality whenever
    user clicks the html button. So I place a hidden server
    control (id = btnComplete) on the .aspx page. In the
    client side code I automatically click the server control
    ( WorkItemForm.btnComplete.click();).

    On the click event of hidden server control, I write the
    server side code in .aspx.cs page.

    // Code in .aspx.cs page

    private void btnComplete_Click(object sender,
    System.EventArgs e)
    {
    // Calling Server Side Code
    }

    I am using btnComplete server control as an intermediate
    to perform server side functionality.

    Problem:

    I want to get rid of server control.
    Is there a way to perform server side functionality
    directly without using server control.

    I tried document.FormName.Submit();

    This doesn't work. Is there some other way to do so?

    Thanks & Regards,
    -Reetu








    Reetu Guest

  2. Similar Questions and Discussions

    1. Time Stamp (User Side/Server Side)
      I am using the following to display time. #TimeFormat(Now(), "h")#:#TimeFormat(Now(), "mm")# #TimeFormat(Now(), "tt")# My problem is the server...
    2. flashcom: client side cant access server side
      hi all, i hav install the flash com on the PC. It work well, on the server PC, i can access and log in to the 'chat room'.. however, if im...
    3. Controls with a client side onLoad function or seting a cursor server side
      Is there any way to create a web control that calls a client side onLoad function? Its diffucilt since you are not able to access the form or...
    4. Client side and server side scripting problem
      Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve...
    5. button evet ---- server side - client side ???
      I want to use button. My question is that How can use server side and client site event at the same time. That is: I want to use button : when...
  3. #2

    Default Re: Server side functionality

    Hi Reetu,

    Here's some VB code that might help you. It uses the submit() method. Not sure
    why it didn't work for you.

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Literal1.Text = "<script>function
    onCompleted(){alert('action');document.forms[0].submit();}</script>"
    If IsPostBack Then
    Label2.Text = "I was posted back at: " & Now.TimeOfDay.ToString
    End If
    End Sub


    <form id="Form1" method="post" runat="server">
    <p>
    <asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
    <p>
    <asp:label id="Label2" runat="server"></asp:label></p>
    <p>
    <asp:label id="Label1" runat="server"></asp:label></p>
    <p>
    <asp:literal id="Literal1" runat="server"></asp:literal></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <input class="sbttn" id="btnComplete0" onclick="onCompleted()"
    type="button" value="Mark Completed"
    name="btnComplete0">
    </form>


    "Reetu" <reetu@ascentn.com> wrote in message
    news:06c901c35c60$5aabcc10$a301280a@phx.gbl...
    Hi All,

    I have an html button on .aspx page.

    <INPUT class="sbttn" id="btnComplete0" onclick="onComplete
    ()" type="button" value="Mark Completed"
    name="btnComplete0">

    When the user clicks on the html button the OnComplete
    function is called.

    <script language="javascript">
    function onComplete()
    {

    // Client side code

    // Clicking the server control via code
    WorkItemForm.btnComplete.click();

    }
    </script>


    I need to perform some server side functinality whenever
    user clicks the html button. So I place a hidden server
    control (id = btnComplete) on the .aspx page. In the
    client side code I automatically click the server control
    ( WorkItemForm.btnComplete.click();).

    On the click event of hidden server control, I write the
    server side code in .aspx.cs page.

    // Code in .aspx.cs page

    private void btnComplete_Click(object sender,
    System.EventArgs e)
    {
    // Calling Server Side Code
    }

    I am using btnComplete server control as an intermediate
    to perform server side functionality.

    Problem:

    I want to get rid of server control.
    Is there a way to perform server side functionality
    directly without using server control.

    I tried document.FormName.Submit();

    This doesn't work. Is there some other way to do so?

    Thanks & Regards,
    -Reetu









    Ken Cox [Microsoft MVP] Guest

  4. #3

    Default Re: Server side functionality

    When your page is loaded, checl the HTML source of your page. Your
    hidden button will not be rendered at all.

    Instead, you can convert your button to a aspx button and add
    Javascript event to it from the code behind using

    Add this line of code to your page load event.
    ButtonName.Attributes.add("onClick","return onComplete()")

    Now when you click on your button it will raise the onclick event on
    the client side and will call onComplete Javascript function. Inside
    the Javascript if you return false, the form will not be submitted and
    the server side event of your button will not fire. If you return
    true, form will be submitted to the server and your button's onclick
    event will be fired on the server.

    ----
    Ram

    "Reetu" <reetu@ascentn.com> wrote in message news:<06c901c35c60$5aabcc10$a301280a@phx.gbl>...
    > Hi All,
    >
    > I have an html button on .aspx page.
    >
    > <INPUT class="sbttn" id="btnComplete0" onclick="onComplete
    > ()" type="button" value="Mark Completed"
    > name="btnComplete0">
    >
    > When the user clicks on the html button the OnComplete
    > function is called.
    >
    > <script language="javascript">
    > function onComplete()
    > {
    >
    > // Client side code
    >
    > // Clicking the server control via code
    > WorkItemForm.btnComplete.click();
    >
    > }
    > </script>
    >
    >
    > I need to perform some server side functinality whenever
    > user clicks the html button. So I place a hidden server
    > control (id = btnComplete) on the .aspx page. In the
    > client side code I automatically click the server control
    > ( WorkItemForm.btnComplete.click();).
    >
    > On the click event of hidden server control, I write the
    > server side code in .aspx.cs page.
    >
    > // Code in .aspx.cs page
    >
    > private void btnComplete_Click(object sender,
    > System.EventArgs e)
    > {
    > // Calling Server Side Code
    > }
    >
    > I am using btnComplete server control as an intermediate
    > to perform server side functionality.
    >
    > Problem:
    >
    > I want to get rid of server control.
    > Is there a way to perform server side functionality
    > directly without using server control.
    >
    > I tried document.FormName.Submit();
    >
    > This doesn't work. Is there some other way to do so?
    >
    > Thanks & Regards,
    > -Reetu
    Ram Guest

  5. #4

    Default Re: Server side functionality


    Thanks a lot, it works.

    Regards,
    -Reetu
    >-----Original Message-----
    >When your page is loaded, checl the HTML source of your
    page. Your
    >hidden button will not be rendered at all.
    >
    >Instead, you can convert your button to a aspx button and
    add
    >Javascript event to it from the code behind using
    >
    >Add this line of code to your page load event.
    >ButtonName.Attributes.add("onClick","return onComplete()")
    >
    >Now when you click on your button it will raise the
    onclick event on
    >the client side and will call onComplete Javascript
    function. Inside
    >the Javascript if you return false, the form will not be
    submitted and
    >the server side event of your button will not fire. If
    you return
    >true, form will be submitted to the server and your
    button's onclick
    >event will be fired on the server.
    >
    >----
    >Ram
    >
    >"Reetu" <reetu@ascentn.com> wrote in message
    news:<06c901c35c60$5aabcc10$a301280a@phx.gbl>...
    >> Hi All,
    >>
    >> I have an html button on .aspx page.
    >>
    >> <INPUT class="sbttn" id="btnComplete0"
    onclick="onComplete
    >> ()" type="button" value="Mark Completed"
    >> name="btnComplete0">
    >>
    >> When the user clicks on the html button the OnComplete
    >> function is called.
    >>
    >> <script language="javascript">
    >> function onComplete()
    >> {
    >>
    >> // Client side code
    >>
    >> // Clicking the server control via code
    >> WorkItemForm.btnComplete.click();
    >>
    >> }
    >> </script>
    >>
    >>
    >> I need to perform some server side functinality
    whenever
    >> user clicks the html button. So I place a hidden server
    >> control (id = btnComplete) on the .aspx page. In the
    >> client side code I automatically click the server
    control
    >> ( WorkItemForm.btnComplete.click();).
    >>
    >> On the click event of hidden server control, I write
    the
    >> server side code in .aspx.cs page.
    >>
    >> // Code in .aspx.cs page
    >>
    >> private void btnComplete_Click(object sender,
    >> System.EventArgs e)
    >> {
    >> // Calling Server Side Code
    >> }
    >>
    >> I am using btnComplete server control as an
    intermediate
    >> to perform server side functionality.
    >>
    >> Problem:
    >>
    >> I want to get rid of server control.
    >> Is there a way to perform server side functionality
    >> directly without using server control.
    >>
    >> I tried document.FormName.Submit();
    >>
    >> This doesn't work. Is there some other way to do so?
    >>
    >> Thanks & Regards,
    >> -Reetu
    >.
    >
    Reetu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139