code-behind

Display image from a datatable in asp:image in code-behind

↘锁芯ラ 提交于 2020-01-11 06:39:25
问题 I have a datatable which is filled from the resultset of a 1 row select statement (via a stored procedure in SQL Server 2008) and it contains a Image typed column which I store images in. I have an asp:image control on an aspx page and i want to set the image to the corresponding field of that datatable but anything I do I can not. Please tell me how can I set the asp:image to image column of that datatable from the code behind . 回答1: Try the Data URL scheme: <img src="<%#

Metro: Why is binding from XAML to a property defined in code-behind not working?

一笑奈何 提交于 2020-01-07 04:26:08
问题 I am attempting to adapt a Windows Metro-style app sample slightly by binding the title text to a property defined in code-behind, but I can't seem to get it to work. Reading the blog post titled Bind from XAML to property defined in code-behind, I am trying out "Solution 1". Here is my XAML source (simplified): <UserControl x:Class="... .MainPage" x:Name="UserControlSelf" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Codebehind file doesn't recognize aspx-controls

允我心安 提交于 2020-01-07 04:22:28
问题 I was given a webproject written with aspx/c#. When I loaded it into Visual Studio 2010, I got many error telling me that some controls in the code-behind files do not exist in the current context. I checked for the common pitfalls, like wrong code-behind file name, missing runat -attribute, restart VS, reload project, yet nothing resolves the error. What else can I do to check where the problem is? 回答1: Try to change the code-behinde to CodeFile="where code locate", then it probably will

Getting binding of transform property from code behind

你。 提交于 2020-01-06 21:14:22
问题 I have code below inside Grid : <Grid.RenderTransform> <TranslateTransform X="{Binding X, Converter={StaticResource HorizontalPositionConverter}}" Y="{Binding Y, Converter={StaticResource VerticalPositionConverter}}" /> </Grid.RenderTransform> How can I get binding of TranslateTransform.X or TranslateTransform.Y in code behind? I found this question but solution works for non-nested dependency properties. What to do when they are? I cannot consider binding to entire RenderTransform . I am

Greying out a button from code-behind does not work in IE

本秂侑毒 提交于 2020-01-06 08:42:14
问题 I have two drop down lists on a page. The behavior is as follows: select something in list 1 list 2 is enabled select something in list 2 button is enabled I am doing the above with autopostback enabled on the drop down lists. To toggle the button I use the code below: if (ddlAvailablePrograms.SelectedValue != string.Empty) { careerInfoLearnMoreSubmit.Enabled = true; careerInfoLearnMoreSubmit.Style.Remove("opacity"); careerInfoLearnMoreSubmit.Style.Add("opacity", "1.0;"); } else {

Greying out a button from code-behind does not work in IE

时光怂恿深爱的人放手 提交于 2020-01-06 08:41:32
问题 I have two drop down lists on a page. The behavior is as follows: select something in list 1 list 2 is enabled select something in list 2 button is enabled I am doing the above with autopostback enabled on the drop down lists. To toggle the button I use the code below: if (ddlAvailablePrograms.SelectedValue != string.Empty) { careerInfoLearnMoreSubmit.Enabled = true; careerInfoLearnMoreSubmit.Style.Remove("opacity"); careerInfoLearnMoreSubmit.Style.Add("opacity", "1.0;"); } else {

calling asp.net codebehind function from javascript

只愿长相守 提交于 2020-01-06 08:09:49
问题 I have custom control called LinkControl : <asp:Panel runat="server"> <script language="javascript" type="text/javascript"> function CheckImage() { var str = document.getElementById('<%=lblBookmarkId.ClientID%>').firstChild.nodeValue; PageMethods.CodebehindCheckImage(str); return false; } </script> <asp:Label runat="server" ID="lblBookmarkId" Style="visibility: hidden;" /> <asp:Button runat="server" ID="btnCheck" Text="Check" OnClientClick="return CheckImage();" CausesValidation="false""/> <

Access HTML controls from code behind C#

旧巷老猫 提交于 2020-01-06 05:49:06
问题 My webpage generates a lot of HTML dynamically using jQuery to display data. However, I need to access those dynamic HTML controls from C#. I cannot do runat="server", because JQUERY does its magic at runtime, depending on what user selects. Is there any way to access the HTML of these dynamically created controls from code behind? Thanks! 回答1: If all you need are values from input fields (input, select, radio, checkbox), just make sure JQuery creates those inside the main <form> tag, then

Wondering about TextBox methods

女生的网名这么多〃 提交于 2020-01-05 12:11:55
问题 I have a TextBox for which I would like to run through a few conditions based on whether or not there is an integer entered in it. My operations take place from the code-behind of the window that the TextBox exists in. Under the LostFocus event I would like to do the following: Check if the string IsNullOrEmpty -If it is - set text to "Default Record" Verify that the entered value is an Int If it isn't - Display a MessageBox(Ok Button) , then set focus back on the TextBox **This is what my

Why should i include the namespace in each aspx page?

橙三吉。 提交于 2020-01-05 03:16:27
问题 I usually include my namespaces e.g. using myProject.Model; to my .cs files but when i want to iterate an object derived from myProject.Model in my .aspx file i must always include the directive <%@ Import Namespace="myProject.Model" %> Why is that? I mean if it is declared in code behind file (in default.aspx.cs) of default.aspx Why should i add it again? Why it is not available? Just wondering but i would like to know why is that. Thank you in advance! 回答1: You can add a namespaces element