5 Replies - 174 Views - Last Post: 10 January 2017 - 03:01 PM

#1 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 92
  • Joined: 20-May 16

when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 09:27 AM

I am using VB and javascript

I have a link. If user click on it than a popup window will show up with textfield, cancel button, and sumbit button.

When user click on sumbit button than I want to Keep the popup window up so I can print some kind of error message.

Issue: when user click on submit button than popup window closes. Maybe in vb code

I think it has to do some thing with postrequest and onclient stuff but I am not not sure what is the solution

<a id="myLink" data-toggle="modal" data-target="#FeedbackModal" data-backdrop="static" data-keyboard="false" href="#"></a>


 <div class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
					<asp:Label ID="error" runat="server" Text=""></asp:Label>
					<asp:TextBox ID="textTB" runat="server" ></asp:TextBox>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="submit" runat="server" Text="Submit" />
                    <button type="button"  data-dismiss="modal">Cancel</button>
                </div>
            </div> <!-- end of mogal-content -->
        </div> <!-- end of modal-dialog -->
    </div><!-- end of modal -->


Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
	Dim tempS As String = textTB.Text

	If (String.IsNullOrEmpty(tempS)) Then
		error.Text = "Error!"
	else
		error.Text = "Success!"
	End If
End Sub


This post has been edited by ikhlas06: 10 January 2017 - 09:34 AM


Is This A Good Question/Topic? 0
  • +

Replies To: when user click on submit button than popup window closes. Maybe in vb

#2 astonecipher  Icon User is offline

  • Licensed PITA
  • member icon

Reputation: 2204
  • View blog
  • Posts: 8,860
  • Joined: 03-December 12

Re: when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 09:59 AM

You can't submit a page through HTML and it not load another page. In order to do that you need an asynchronous call, ie ajax.
Was This Post Helpful? 1
  • +
  • -

#3 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 92
  • Joined: 20-May 16

Re: when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 11:26 AM

View Postastonecipher, on 10 January 2017 - 09:59 AM, said:

You can't submit a page through HTML and it not load another page. In order to do that you need an asynchronous call, ie ajax.




I did use ajax but still running into same issue


Master.Page.master
  <script type="text/javascript">
                $(function () {
                    $("#submit").click(function () {
                        $.ajax({
                            type: "POST",
                            url: " MasterPage.master/validation",
                            data: '{}',
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (r) {
                                alert(r.d);
                            },
                            error: function (r) {
                                alert(r.d);
                            }
                        });
                    });
                });
        </script>


<a id="myLink" data-toggle="modal" data-target="#FeedbackModal" data-backdrop="static" data-keyboard="false" href="#"></a>

<div class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
					<asp:Label ID="error" runat="server" Text=""></asp:Label>
					<asp:TextBox ID="textTB" runat="server" ></asp:TextBox>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="submit" runat="server" Text="Submit" />
                    <button type="button"  data-dismiss="modal">Cancel</button>
                </div>
            </div> <!-- end of mogal-content -->
        </div> <!-- end of modal-dialog -->
</div><!-- end of modal -->



Master.Page.master.vb

<WebMethod()> _
Public Shared Function validation()
	Return "testing "
End Function


Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1543
  • View blog
  • Posts: 5,018
  • Joined: 15-January 14

Re: when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 11:42 AM

Are you seeing that alert box? It doesn't look like you're canceling the default submit event, so it will still submit the form.
Was This Post Helpful? 1
  • +
  • -

#5 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 92
  • Joined: 20-May 16

Re: when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 12:13 PM

I did some debugging and I got a 403 error. I belive this means my JS and ajax code is fine. Issue might be in VB function.

error alert:
readyState: 4
status: 403
text: error
error: Forbidden


<input ID="Submit" type="button" onclick="validationJS();" value="Submit" />

  <script type="text/javascript">
            function validationJS() {
                var name = $("#textTB").val();
                $.ajax({
                    type: "POST",
                    url: " MasterPage.master/validationVB",
                    data: '{name: "' + name + '" }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnSuccess,
                    failure: OnFailure,
                    error: onerror
                });
            }
            function OnSuccess(response) {
                alert("S: " + response.d);
            }
            function OnFailure(response) {
                alert("F: " + response.d);
            }
            function onerror(xhr, textStatus, err) {
               alert("readyState: " + xhr.readyState);
               alert("responseText: " + xhr.responseText);
               alert("status: " + xhr.status);
               alert("text status: " + textStatus);
               alert("error: " + err);
            }
        </script>


    <System.Web.Services.WebMethod()> _
    Public Shared Function validationVB(ByVal name As String) As String
        Return "Hello "
    End Function

Was This Post Helpful? 0
  • +
  • -

#6 astonecipher  Icon User is offline

  • Licensed PITA
  • member icon

Reputation: 2204
  • View blog
  • Posts: 8,860
  • Joined: 03-December 12

Re: when user click on submit button than popup window closes. Maybe in vb

Posted 10 January 2017 - 03:01 PM

You're hitting an api, right?

Test tje api using postman. It's a google chrome app specifically for testing api's.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1