HTML INPUT button to call server side code?

I am trying to create a simple webpage that will allow my users to reset there passwords.  I want my page to list basic user information (ID, PW expiration, isLocked, Deactivated) and in the last column I want a button that when pressed, prompts the user to input a new password.

I have found two things so far:
-ASP buttons cannot be dropped into a DIV block
-HTML INPUT buttons cannot call server side script

Can someone help me out with a simple solution?  I am willing to try some other methods, however I am new to vb.net and I don't have a lot of time to get this out.

Thanks,

LB
Function scrollUser(ByVal cai As String, ByVal ds As DataSet) As String

        Dim getData As New returnData()

        Dim userTable As String = "<table border = '1'><tr><td>User Code</td><td>Description</td><td>Is Active? </td><td>Valid Password</td><td>Account Locked?</td><td>Reset Password</td></tr>"
        Dim r As Integer
        Dim c As Integer


        Dim objConnect As OleDbConnection = getData.getConn
        objConnect.Open()
        Dim USR_CODE As String = String.Empty
        Dim isValid As Boolean
        Dim notValid As String = ""
        Dim DSd As DataSet = New DataSet
        usercai.Text = cai
        Try
            Dim DA As OleDbDataAdapter = getData.TESTgetUserData("TCME%", objConnect)

            DA.Fill(DSd)


            For r = 0 To DSd.Tables(0).Rows.Count - 1
                userTable = userTable + "<tr>"
                For c = 0 To 5
                    If c = 2 Then
                        If DSd.Tables(0).Rows(r)(c).ToString() = "+" Then
                            userTable = userTable + "<td>Active</td>"
                        ElseIf DSd.Tables(0).Rows(r)(c).ToString() = "-" Then
                            userTable = userTable + "<td>Not Active</td>"
                        End If
                    ElseIf c = 4 Then
                        If DSd.Tables(0).Rows(r)(c).ToString() = "5" Then
                            userTable = userTable + "<td>Locked</td>"
                        Else
                            userTable = userTable + "<td>Open</td>"
                        End If
                    ElseIf c = 5 Then
                        userTable = userTable + "<td><input type='button' onclick='createform(" + DSd.Tables(0).Rows(r)(0).ToString() + ")' name='text' runat='server' Value='Reset Password (Unlock)'></td>"

                    Else
                        userTable = userTable + "<td>" + DSd.Tables(0).Rows(r)(c).ToString() + "</td>"
                    End If
                Next
                userTable = userTable + "</tr>"
            Next
            userTable = userTable + "</table>"

            userDisplay.InnerHtml = userTable

            objConnect.Close()

        Catch objError As Exception
            outError.InnerHtml = "<b>* Error </b>.<br />" + objError.Message + "<br />" + objError.Source
            objConnect.Close()

        Finally

            objConnect.Close()
        End Try

        If isValid = True Then
            Return USR_CODE
        Else
            Return notValid
        End If

    End Function

Open in new window

lawrencebensonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
Why do you want to put the button into DIV tag?
HTML input control add the runat="server"

I blv  you are using ASP.Net and not classic ASP
0
Akin DeluI’m a software engineer, tech enthusiast and UI/UX lover. Commented:
About your findings
 "ASP buttons cannot be dropped into a DIV block" thats prety strange, i guess you are doing something wrong.
also "-HTML INPUT buttons cannot call server side script", you can make it call a server script, add the runat="server" and onserverclick="methodtocall" to the property of the html button element.
0
lawrencebensonAuthor Commented:
First comment:

Very likely.  That is why I am on here.  Any suggestions as to how to use the ASP button correctly within my code?

Second comment:

I have runat=server in there already.  I switched onClick to onServerClick='createform()' and when I press the button nothing happens.


LB
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

lawrencebensonAuthor Commented:
@SriVaddadi
Well this is the method I learned when I was at school (classic ASP).  I am learning now that it does not translate over to webapps very well.
0
lawrencebensonAuthor Commented:
Increasing the point value...
0
Amandeep Singh BhullarCommented:
You call call the server code to reset password using AJAX.

This will solve your problem of calling server side script.
0
lawrencebensonAuthor Commented:
Can you point me in the right direction of an example?  The examples I have found seem pretty drawn out.
0
lawrencebensonAuthor Commented:
Perhaps looping through and creating the table is a dated method :D

If you could suggest another method that would allow me to put a button on each line I could pursue that.  Although, this code done already so I would hate to abandon it.
0
Akin DeluI’m a software engineer, tech enthusiast and UI/UX lover. Commented:
this is a sample test i ran and it works.
On the html page i have this
<input id="Button2" onserverclick="Button2_ServerClick" runat="server" type="button" value="button" />
At the backend i have this
Protected Sub Button2_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ServerClick
        Response.Write("JUST A TEST")
    End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lawrencebensonAuthor Commented:
Thanks for the code!  
0
lawrencebensonAuthor Commented:
I did not end up using this solution but it does work.  I setup a repeater the day before and that has worked great.  Here is the code I used...
<asp:Repeater ID="usrList" runat="server">
            <HeaderTemplate>
                <table border="1" >
                <tr>
                <th width=50px >User ID</th>
                <th width=80px>Description</th>
                <th>Is Active?</th>
                <th>Valid Password?</th>
                <th>Account Locked?</th>
                <th>Update Password</th>
                
                </tr>
            </HeaderTemplate>

            <ItemTemplate>
                <tr>
                <td><%#DataBinder.Eval(Container.DataItem, "usr_code")%></td>
                <td><%#DataBinder.Eval(Container.DataItem, "usr_desc")%></td>
                <td><%#DataBinder.Eval(Container.DataItem, "usr_active")%></td>
                <td><%#DataBinder.Eval(Container.DataItem, "ISEXPIRED")%></td>
                <td><%#DataBinder.Eval(Container.DataItem, "usr_violations")%></td>
                <td><asp:button runat="Server" OnCommand="createForm" commandname="spam" CommandArgument =<%#DataBinder.Eval(Container.DataItem, "usr_code")%> text="Reset Password" /></td>
                

                </tr>
            </ItemTemplate>

            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>



<--Script

 Sub repeaterUSer(ByVal cai As String, ByVal DS As DataSet)
        

        Dim getData As New returnData()

        
        Dim objConnect As OleDbConnection = getData.getConn
        objConnect.Open()
        Dim USRCODE As String = String.Empty
        Dim notValid As String = ""
        Dim DSd As DataSet = New DataSet
        'Dim DS As DataSet = New DataSet
        usercai.Text = cai
        'DS.ReadXml(MapPath("usrList.xml"))
        If (IsPostBack) = False Then
            Try
                Dim DA As OleDbDataAdapter = getData.TESTgetUserData(cai + "%", objConnect)

                DA.Fill(DSd)
                usrList.DataSource = DSd
                usrList.DataBind()
                objConnect.Close()

            Catch objError As Exception
                outError.InnerHtml = "<b>* Error </b>.<br />" + objError.Message + "<br />" + objError.Source
                objConnect.Close()

            Finally

                objConnect.Close()
            End Try
        End If

    End Sub

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.