Jquery 是否在VB.NET中不单击按钮进行回发?

Jquery 是否在VB.NET中不单击按钮进行回发?,jquery,asp.net,vb.net,postback,Jquery,Asp.net,Vb.net,Postback,我的代码当前要求我单击按钮将信息发布回服务器,是否有任何方法可以使用代码自动执行此操作,基本上是模拟单击按钮,或者更好,不使用任何按钮将其发布回服务器 ASPX代码: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1" %> <%@ Register

我的代码当前要求我单击按钮将信息发布回服务器,是否有任何方法可以使用代码自动执行此操作,基本上是模拟单击按钮,或者更好,不使用任何按钮将其发布回服务器

ASPX代码:

           <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1" %>

                <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

                <!DOCTYPE html>


                  <form id="form1" runat="server">
                      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                          <Scripts>
                              <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                              </asp:ScriptReference>
                              <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                              </asp:ScriptReference>
                              <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                              </asp:ScriptReference>
                          </Scripts>
                      </telerik:RadScriptManager>


                  <asp:HiddenField runat="server" ID="svgHolder" />
    <asp:Button ID="Button1" Text="Export the RadHtmlChart" OnClientClick="getSvgContent(this);"
            runat="server" />
    <table class="clearTable2" style="page-break-after: avoid;">
        <tr>
            <td class="clearTable1"></td>
            <td class="clearTable2">
                <asp:Label ID="lblSectionTitle" runat="server" CssClass="label2"></asp:Label>
            </td>
            <td class="clearTable1"></td>
        </tr>
    </table>
    <table class="clearTable2">
        <tr>
            <td class="clearTable1"></td>
            <td class="clearTable1" style="width: 100%; visibility: visible">

                <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1">
                    <Legend>
                        <Appearance Position="Bottom">
                            <TextStyle FontSize="14" Color="Blue" FontFamily="Courier New, sans-serif" />
                        </Appearance>
                    </Legend>
                    <PlotArea>
                        <XAxis>
                            <Items>
                                <telerik:AxisItem LabelText="KM41872"/>
                                <telerik:AxisItem LabelText="KM41873"/>
                                <telerik:AxisItem LabelText="KM41871"/>
                            </Items>
                            <MajorGridLines Visible="false" />
                            <MinorGridLines Visible="false" />
                        </XAxis>
                        <YAxis>
                            <MinorGridLines Visible="false" />
                        </YAxis>
                        <Series>
                            <telerik:LineSeries Name="Mean">
                                <SeriesItems>
                                    <telerik:CategorySeriesItem Y="0.59" />
                                    <telerik:CategorySeriesItem Y="0.63" />
                                    <telerik:CategorySeriesItem Y="0.6" />
                                    <telerik:CategorySeriesItem Y="0.65" />
                                    <telerik:CategorySeriesItem Y="0.64" />
                                    <telerik:CategorySeriesItem Y="0.63" />
                                    <telerik:CategorySeriesItem Y="0.65" />
                                    <telerik:CategorySeriesItem Y="0.67" />
                                    <telerik:CategorySeriesItem Y="0.63" />
                                </SeriesItems>
                            </telerik:LineSeries>
                            <telerik:LineSeries Name="Min">
                                <SeriesItems>
                                    <telerik:CategorySeriesItem Y="0.55" />
                                    <telerik:CategorySeriesItem Y="0.56" />
                                    <telerik:CategorySeriesItem Y="0.55" />
                                    <telerik:CategorySeriesItem Y="0.61" />
                                    <telerik:CategorySeriesItem Y="0.56" />
                                    <telerik:CategorySeriesItem Y="0.57" />
                                    <telerik:CategorySeriesItem Y="0.59" />
                                    <telerik:CategorySeriesItem Y="0.61" />
                                    <telerik:CategorySeriesItem Y="0.55" />
                                </SeriesItems>
                            </telerik:LineSeries>
                            <telerik:LineSeries Name="Max">
                                <SeriesItems>
                                    <telerik:CategorySeriesItem Y="0.66" />
                                    <telerik:CategorySeriesItem Y="0.74" />
                                    <telerik:CategorySeriesItem Y="0.66" />
                                    <telerik:CategorySeriesItem Y="0.71" />
                                    <telerik:CategorySeriesItem Y="0.72" />
                                    <telerik:CategorySeriesItem Y="0.73" />
                                    <telerik:CategorySeriesItem Y="0.71" />
                                    <telerik:CategorySeriesItem Y="0.74" />
                                    <telerik:CategorySeriesItem Y="0.71" />
                                </SeriesItems>
                            </telerik:LineSeries>
                        </Series>
                    </PlotArea>
                </telerik:RadHtmlChart>
            </td>
            <td class="clearTable1"></td>
        </tr>
    </table>
    <script type="text/javascript">
        function getSvgContent(sender) {
            //obtain an SVG version of the chart regardless of the browser
            var chartRendering = $find("<%=RadHtmlChart1.ClientID %>").getSVGString();
            //store the SVG string in a hidden field and escape it so that the value can be posted to the server
            document.getElementById('<%=svgHolder.ClientID%>').value = escape(chartRendering);
            //initiate the postback from the button so that its server-side handler is executed
            __doPostBack(sender.name, "");
            $('#Button1').click();
        }
    </script>
                      <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>

我认为您需要的是_udopostback javascript函数(google it)。它实际上是从.Net控件中伪造回发事件,所以它的工作方式就像单击按钮一样。如果您不想显示按钮,但仍然挂接按钮进行回发,也可以设置按钮的diplay:hidden属性。

将JavaScript挂接到希望页面回发的客户端事件。然后使用JavaScript“单击”事件处理程序中的按钮;在我的代码中,模拟“单击”,但它似乎没有效果。您的代码执行一些客户端操作,然后将发回服务器。很可能这不是您想要的,因为您将丢失客户端更改。您在问题中还表示希望删除该按钮,但没有说明何时运行(运行事件应该连接到)。我基本上只想接收htmlchart的svg部分,但现在只有在浏览器中加载的aspx页面上单击该按钮时,它才起作用。如果可能的话,我希望它能自动发送回去。我理解这一点,但你需要明白,事情并不仅仅是自己发生的,你必须把它们与某个事件联系起来。这叫做事件驱动。如果希望它在服务器端自动执行某些操作,那么应该在服务器端使用Page_Load方法,这样就不需要JavaScript了。否则,如果您想在客户端执行此操作,请找出需要运行它以响应的事件,然后通过模拟按钮单击或直接调用
\uuu doPosBack
,将其连接到该事件。此发回是特定对象吗?是。。。只需创建一个按钮,通过使用div MYBUTTON将其包装,使其隐藏在页面上。然后使用该按钮进行回发。这样,你甚至可以在服务器上用指定的事件方便地处理它。这是我不知道的,未经测试。。。然后$(“#lbtnRibbonChanged”)。单击()这比调用uu doPostBack简单,但是如果不想使用按钮并且需要回发特定控件,则u doPostBack可能很有用。如果您只想触发回发并在服务器上处理,这是最好的方法。确保ClientIDMode是静态的,这样它就可以找到按钮。现在,我所拥有的功能不起作用,我必须实际单击按钮,以便出于某种原因将其发回,但是,我试图完成的是加载已经完成回发的页面,或者模拟它。为了获得额外的好处,您可以通过使用[webmethod]对服务器端页面方法进行ajax装饰来实现无缝连接。删除带有按钮名称的sender.name。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Button1.Text = HttpUtility.UrlDecode(svgHolder.Value)

End Sub


'Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'    Dim svgText As String = HttpUtility.UrlDecode(svgHolder.Value)
'End Sub
End Class
function DoPostBack(obj) {
            __doPostBack(obj.id, 'OtherParams');
}

Just call __doPostBack