开发者

Onclick not firing

开发者 https://www.devze.com 2022-12-27 04:52 出处:网络
I have a set of buttons on my master page (I have attached the code below) but no onclick event is being raised. I pulled the final page source and no onclick event was present. As you can see I tried

I have a set of buttons on my master page (I have attached the code below) but no onclick event is being raised. I pulled the final page source and no onclick event was present. As you can see I tried a few different approaches to solve the problem. I am looking for a normal postback to the server but I am getting nothing when I click any of these buttons.

What am I not doing?

--Master

<asp:Button ID="btnSubmit" CssClass="btn" runat="server" OnClick ="Button_Click" />
<asp:Button ID="btnSave" CssClass="btn" CommandArgument="1" CommandName="ButtonPress" runat="server" OnClick="Button_Click" />
<asp:Button ID="btnClear" CssClass="btn" CommandArgument="8" CommandName="ButtonPress" runat="server" OnCommand="Button_Command" />
<asp:Button ID="btnCancel" CssClass="btn" CommandArgument="4" CommandName="ButtonPress" runat="server" OnCommand="Button_Command" />

--Master Code Behind

Protected Sub Button_Command(ByVal sender As Object, ByVal e As CommandEventArgs) Handles btnCancel.Command, btnClear.Command
    Session("ButtonClicked") = e.CommandArgument
End Sub

Protected Sub Button_Click(ByVal sender As Object, ByV开发者_JAVA技巧al e As EventArgs) Handles btnSave.Click, btnSubmit.Click
    Session("ButtonClicked") = CType(sender, Button).CommandArgument
End Sub 

--Page Source

<input type="submit" name="ctl00$btnSubmit" value="Submit" id="ctl00_btnSubmit" class="btn" />
<input type="submit" name="ctl00$btnSave" value="Save" id="ctl00_btnSave" class="btn" /> 
<input type="submit" name="ctl00$btnClear" value="Clear" id="ctl00_btnClear" class="btn" />
<input type="submit" name="ctl00$btnCancel" value="Cancel" id="ctl00_btnCancel" class="btn" />


I found the issue. Here was the problem. On the master Page I had to change this:

< script language="javascript" src="scriptLibrary.js" type="text/javascript"/>

To this:

< script language="javascript" src="scriptLibrary.js" type="text/javascript">< /script>

And after that it performed a normal postback without errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号