Force POSTBACK

Asked

Viewed 468 times

0

I’m passing information on the variable click_teste for a TextBox with id others that TextBox is a parameter for a query of a Gridview.

I need that when receiving the data the textbox make one PostBack, today I have to give a Enter or click on another control.

Textbox:

<asp:TextBox ID="outros" runat="server" 
             AutoPostBack="true" clientIdMode="static" 
             OnTextChanged="outros_TextChanged">
dados
</asp:TextBox>    

Method pass data:

document.getElementById('outros').value = click_teste;

(function (marker, data) {
                      google.maps.event.addListener(marker, "click", function (e) {

                          var click_teste = data.title;
                          document.getElementById('outros').value = click_teste;



                          //alert(click_teste);

                          infoWindow.setContent(data.description);
                          infoWindow.open(map, marker);
                          alert(click_teste);
                      });
                  })


     <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" DataKeyNames="id_programacao_correcao" DataSourceID="SqlDataSource8">
            <Columns>
                <asp:BoundField DataField="id_programacao_correcao" HeaderText="id_programacao_correcao" ReadOnly="True" InsertVisible="False" SortExpression="id_programacao_correcao"></asp:BoundField>
                <asp:BoundField DataField="id_projeto" HeaderText="id_projeto" SortExpression="id_projeto"></asp:BoundField>
                <asp:BoundField DataField="turma" HeaderText="turma" SortExpression="turma"></asp:BoundField>
                <asp:CheckBoxField DataField="deligamento" HeaderText="deligamento" SortExpression="deligamento"></asp:CheckBoxField>
                <asp:CheckBoxField DataField="linha_viva" HeaderText="linha_viva" SortExpression="linha_viva"></asp:CheckBoxField>
                <asp:BoundField DataField="supervisor" HeaderText="supervisor" SortExpression="supervisor"></asp:BoundField>
                <asp:BoundField DataField="eps" HeaderText="eps" SortExpression="eps"></asp:BoundField>
                <asp:BoundField DataField="si" HeaderText="si" SortExpression="si"></asp:BoundField>
                <asp:BoundField DataField="data_execucao" HeaderText="data_execucao" SortExpression="data_execucao"></asp:BoundField>
                <asp:BoundField DataField="ref" HeaderText="ref" SortExpression="ref"></asp:BoundField>
                <asp:CheckBoxField DataField="conclusao_correcao" HeaderText="conclusao_correcao" SortExpression="conclusao_correcao"></asp:CheckBoxField>
            </Columns>
        </asp:GridView>


        <asp:SqlDataSource runat="server" ID="SqlDataSource8" ConnectionString='<%$ ConnectionStrings:COEX_RPBConnectionString %>' SelectCommand="SELECT [id_programacao_correcao], [id_projeto], [turma], [deligamento], [linha_viva], [supervisor], [eps], [si], [data_execucao], [ref], [conclusao_correcao] FROM [tbl_programacoes_correcao] WHERE ([ref] = @ref)">
            <SelectParameters>
                <asp:ControlParameter ControlID="outros" PropertyName="Text" Name="ref" Type="String" DefaultValue="A200675"></asp:ControlParameter>
            </SelectParameters>
        </asp:SqlDataSource>
    <asp:TextBox ID="outros" runat="server" AutoPostBack="true" clientIdMode="static" OnTextChanged="outros_TextChanged"> dados</asp:TextBox>
  • What is the moment that receives the value, has as an example?

  • I am using the Google Maps API, when I click on a marker I store the name of the marker in the click_test variable I pass this value to the other field and perform the query in the database using a gridview. The problem is that I have to perform the postback in the field other otherwise the gridview does not appear.

  • (Function (Marker, data) { google.maps.Event.addListener(Marker, "click", Function e) { var click_test = data.title; Document.getElementById('other'). value = click_test; //Alert(click_test); infowindow.setContent(data.Description); infowindow.open(map, Marker); Alert(click_test); }); })

  • You could put all the code?

  • All code not pq is very large, but follows the parts that sited.

  • You can [Edit] your question and add new information.

Show 1 more comment

1 answer

1

You can use the "__doPostBack" function, example:

function suafuncao() {
    document.getElementById("<%=outros.ClientID%>").value = click_teste;
    __doPostBack("<%=outros.ClientID%>", "");
}
  • Hello marcelogribeiro, your code helped me partially, solved the postback problem but the gridview this dento of a modal and it ends up closing alone. how would you look to give the postback and keep the modal open? Function openModal() { $('[id*=modal_ICO]'). modal('show'); }

  • Try to place your textbox inside an updatepanel: <Asp:Updatepanel ID="Updatepanel1" runat="server"> <Contenttemplate> <Asp:Textbox ID="other" runat="server" Autopostback="true" clientIdMode="Static" Ontextchanged="outros_TextChanged">data </Asp:Textbox> </Contenttemplate> </Asp:Updatepanel>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.