servercontrols

ASP.Net LinkButton CommandArgument property ignores <%= .. %>

孤街浪徒 提交于 2019-12-01 09:50:35
I'm trying to do what I thought was a very simple operation to set a property on an ASP.Net LinkButton control but for some reason ASP.Net is ignoring the tags and just passing through the value as a string. <asp:LinkButton id="viewDetails" runat="server" Text="Details" OnClick="btnDetails_Click" CommandName="ItemID" CommandArgument="<%= item.ItemID %>" /> When the link is clicked I handle it with: protected void btnDetails_Click(object sender, EventArgs e) { try { LinkButton btn = (LinkButton)sender; if (btn.CommandName == "ItemID") { string itemID = btn.CommandArgument.ToString(); } } catch

Add <Script … /> tag within <Head … /> tag in ServerControl (ASP.NET)?

吃可爱长大的小学妹 提交于 2019-12-01 07:28:04
问题 I'm gonna use JQuery files in my custom ServerControl , thus I have to add below line within Head tag. <script type="text/javascript" src="jquery-1.4.3.min.js"></script> How can I do it in ServerControl with C# 回答1: You can register custom scripts using the ClientScriptManager.RegisterClientScriptInclude Method during the page load. Alternatively, you can just include the script in your .aspx page. If this is a public server control, the first method is probably more preferable. EDIT:

ASP.Net web server control that generates HTML and Excel

心已入冬 提交于 2019-12-01 07:17:07
问题 I am developing a web application that contains a great deal of reporting. The reports are fairly basic, but some have multiple datasets or embedded charts. One of the key requirements is that each report can be exported to Excel. The Excel version of the report is disconnected and should look the same (or very similar) to the web report. That includes formmating of values, cell styles, number of rows/columns, charts, etc. The problem I've encountered is that the ASP.Net reporting tools I've

ASP.Net LinkButton CommandArgument property ignores <%= .. %>

谁都会走 提交于 2019-12-01 06:02:40
问题 I'm trying to do what I thought was a very simple operation to set a property on an ASP.Net LinkButton control but for some reason ASP.Net is ignoring the tags and just passing through the value as a string. <asp:LinkButton id="viewDetails" runat="server" Text="Details" OnClick="btnDetails_Click" CommandName="ItemID" CommandArgument="<%= item.ItemID %>" /> When the link is clicked I handle it with: protected void btnDetails_Click(object sender, EventArgs e) { try { LinkButton btn =

Excel like server side control for ASP.NET

牧云@^-^@ 提交于 2019-11-30 18:11:02
问题 We have a requirement to increase the functionality of a grid we are using to edit on our webapp, and our manager keeps citing Excel as the perfect example for a data grid :/ He still doesn't really get that a Spreadsheet like control doesn't exist out of the box, but I thought I'd do a bit of searching nonetheless. I've found a couple of products on Google, but was wondering if anyone else has any feedback around any such controls (obviously the cheaper or ahem freer the better) EDIT We do

How do I make my ASP.NET server control take an embedded code block as a property value?

拥有回忆 提交于 2019-11-30 07:24:35
I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so: <cc1:customControl runat="server" Title='<%= PagePropertyValue%>' > more content </cc1:customControl> When I do this, however, I am getting the exact String <%= PagePropertyValue%> being displayed rather than the Property Value that I would like to see. So after trying the databinding expression (as suggested below). I don't get the string literal that looked bad but I don't get anything else either. <cc1:customControl runat="server" Title='<%#

Creating an asp:Button programmatically?

牧云@^-^@ 提交于 2019-11-29 13:44:55
I'm using my code-behind page to create a save button programmatically: Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; However I think this must create an html button or perhaps needs something else as I cannot seem to set the OnClick attribute in the following line, I can specify OnClientClick but this isn't the one I want to set. Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; btnSave.Click += new System.EventHandler(btnSave_Click); protected void btnSave_Click(object sender, EventArgs e) { //do something when button clicked. }

ASP.NET Server Control Property Attribute must be required

橙三吉。 提交于 2019-11-29 11:25:49
I have a custom ASP.NET server control CustomControl with a property attribute Path . If the Path is not explicitly specified, then I want an exception to be thrown. For example, <myControls:CustomControl Path="somedirectory/someotherdirectory/somefile.ext" runat="server" /> should compile, and <myControls:CustomControl runat="server" /> should throw an exception. I realize I can do this in the getter of the Path property, but is there some attribute that necessitates this? Update Is there any mechanism for validating the values of the property attributes other than using in the getter methods

How do I make my ASP.NET server control take an embedded code block as a property value?

为君一笑 提交于 2019-11-29 10:25:11
问题 I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so: <cc1:customControl runat="server" Title='<%= PagePropertyValue%>' > more content </cc1:customControl> When I do this, however, I am getting the exact String <%= PagePropertyValue%> being displayed rather than the Property Value that I would like to see. So after trying the databinding expression (as suggested below). I don't get the string literal

retrieve ID of server control using jQuery

半城伤御伤魂 提交于 2019-11-28 12:17:06
How do I get the ID of a server control with jQuery? E.g. I have <asp:Label ID="label1" runat="server""></asp:Label> and now I want to get "label1", var id = ?? If you use ASP.NET 4.0 you can set attribute ClientIDMode="Static" and your code will looks following way: <asp:Label ID="label1" runat="server" ClientIDMode="Static"></asp:Label> js: var id = 'label1'; var labelID = $('#<%= label1.ClientID %>'); You need to get the client ID. If you just need the ID, and not the actual value of the control, then you don't even need jQuery. var labelID = '<%= label1.ClientID %>'; Roman var $lblObj = $(