locked
image inside div inside loop with button RRS feed

  • Question

  • User1203467145 posted

    in asp.net please i want to put image and many information from sql inside div in code behind and i want to use loop like that <whille(dr.read() { //code ........... })> can you please tel me how and second inside of this loop i have button how can i know he button clicked 

    Tuesday, March 20, 2018 10:39 PM

All replies

  • User61956409 posted

    Hi ayma,

    Welcome to ASP.NET forum.

    It seems that you’d like to retrieve rows from a data source using DataReader and dynamically generate&append html (or asp.net controls) to your web page. You can try to add an ASP.NET Panel control to your page and then dynamically add controls and static text to that Panel control.

    With Regards,

    Fei Han

    Wednesday, March 21, 2018 8:52 AM
  • User1203467145 posted

    how can i know the button clicked can you please tell me the method

    Wednesday, March 21, 2018 12:12 PM
  • User61956409 posted

    Hi ayma,

    To prevent dynamically generated controllers from reloading or disappearing after click button causing post back, you can attach click event to your button with the .on() method and make ajax request to webmethod or service to process data etc instead of posting the form.

    $("#btnok").on("click", function (e) {
        //here make ajax request
    
        //Prevent button from submitting a form
        e.preventDefault();
    })
    

    With Regards,

    Fei Han

    Sunday, March 25, 2018 2:11 AM