locked
Run sqlStatment (Dqldatasource) when I open modal RRS feed

  • Question

  • User-909867351 posted

    I fullcalendar I have the following code:

    eventClick: function (calEvent, jsEvent, view) {                
                    $("#HiddenField2").val(calEvent.id_cliente); 
                    $("#HiddenField1").val(calEvent.id);
                    $("#modalConsulta").modal();

    I pass the values of calEnvent.id_cliente and calEvent.id_cliente to modalConsuta. I have to run one sqldatasource select statment to get all the data from my table like this one

    SqlDataSource1.SelectParameters.Clear();
            SqlDataSource1.SelectCommand = "select * from clientes where id=?";
            SqlDataSource1.SelectParameters.Add("@a", HiddenField2.Value);
            SqlDataSource1.DataBind();

    and show the values on modalConsulta

    Any help on this issue?

    Thank you

    Monday, July 22, 2019 11:24 AM

Answers

  • User475983607 posted

    The problem is click() works in Button4 and hide() does not work

    My source code

    <input type="hidden" name="HiddenField1" id="HiddenField1" value="67" />
                            <input type="hidden" name="HiddenField2" id="HiddenField2" value="3" />
                            <input type="submit" name="Button4" value="Procura" id="Button4" />

    Why click() works ans hide does not work?

    The click happens before the hide().  If the click is a full page refresh then the button CSS (state) is generated on the server which overwrites the HTML.  Please use your debugging tools.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 22, 2019 3:36 PM

All replies

  • User475983607 posted

    A standard ASP.NET Web Forms Update Panel is required to invoke an SqlDataSource because an SqlDataSource is a member of the of the page class. 

    A very common approach is using AJAX or fetch to invoke an HTTP request to an HTTP endpoint.  Then writing a bit of JavaScript to update the DOM. 

    Monday, July 22, 2019 11:35 AM
  • User-909867351 posted

    If I have one button with the sqlStatment on my modal I can run it (with click event) like this

    $("#HiddenField2").val(calEvent.id_cliente); 
                    $("#HiddenField1").val(calEvent.id);
                    
                    $("#Button4").click();               
                    $("#modalConsulta").modal();

    And works fine. My problem: How can I hide Button4 after click?

    Monday, July 22, 2019 12:08 PM
  • User475983607 posted

    And works fine. My problem: How can I hide Button4 after click?

    $("#Button4").hide();

    jQuery Reference

    https://api.jquery.com/hide/

    Monday, July 22, 2019 12:35 PM
  • User-909867351 posted

    I try it but no luck

    The Button is still visible

    $("#Button4").click();  
                    $("#Button4").hide();
                    $("#modalConsulta").modal();

    Maybe after sqldatasource complets the sql statment I will put the button visible=false. I don't understand why hide() is not working.

    Monday, July 22, 2019 1:49 PM
  • User475983607 posted

    I don't understand why hide() is not working.

    Have you verified the code is running by setting a break point?

    Maybe you are using a content page and need to use the following construct?

    $("#<%=Button4.ClientID%>").hide();

    We cannot see all the relevant code so we are guessing how your code works at this point.

    Monday, July 22, 2019 1:53 PM
  • User-909867351 posted

    The problem is click() works in Button4 and hide() does not work

    My source code

    <input type="hidden" name="HiddenField1" id="HiddenField1" value="67" />
                            <input type="hidden" name="HiddenField2" id="HiddenField2" value="3" />
                            <input type="submit" name="Button4" value="Procura" id="Button4" />
    

    Why click() works ans hide does not work?

    Monday, July 22, 2019 3:27 PM
  • User475983607 posted

    The problem is click() works in Button4 and hide() does not work

    My source code

    <input type="hidden" name="HiddenField1" id="HiddenField1" value="67" />
                            <input type="hidden" name="HiddenField2" id="HiddenField2" value="3" />
                            <input type="submit" name="Button4" value="Procura" id="Button4" />

    Why click() works ans hide does not work?

    The click happens before the hide().  If the click is a full page refresh then the button CSS (state) is generated on the server which overwrites the HTML.  Please use your debugging tools.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 22, 2019 3:36 PM