code-behind

Adding Html from Code Behind in Asp.net

我们两清 提交于 2019-11-30 00:46:02
问题 I want to add HTML structure and control like this from code behind into a panel <div class='Main'> <div class='cst'> First Name </div> <div class='csc'> <asp:Label ID="lblFirstName" CssClass="ronly" runat="server"></asp:Label> </div> <div class='cst'> First Name </div> <div class='csc'> <asp:Label ID="lblFirstName" CssClass="ronly" runat="server"></asp:Label> </div> <div class='cst'> First Name </div> <div class='csc'> <asp:Label ID="lblFirstName" CssClass="ronly" runat="server"></asp:Label>

Windows form/WPF too large, how can i split it up?

醉酒当歌 提交于 2019-11-29 21:43:50
问题 I'm about to create WPF application. So far at uni the only way we have ever done GUIs is to have one main window with one code-behind file for handling its button clicks etc.. My issue is that as the application grows, the GUI grows, and the size of the code behind file can get really out of hand! I have identified about 15 main use cases for my system (example: enter details, view details, etc...). I am creating a main window (size: 480x320) that consists of 15 seperate screens (one for

How to assign a dynamic resource style in code?

点点圈 提交于 2019-11-29 20:25:45
I want to produce in code the equivalent of this in XAML: <TextBlock Text="Title:" Width="{Binding FormLabelColumnWidth}" Style="{DynamicResource FormLabelStyle}"/> I can do the text and the width, but how do I assign the dynamic resource to the style: TextBlock tb = new TextBlock(); tb.Text = "Title:"; tb.Width = FormLabelColumnWidth; tb.Style = ??? You can try: tb.Style = (Style)FindResource("FormLabelStyle"); Enjoy! Samuel Jack You should use FrameworkElement.SetResourceReference if you want true DynamicResource behaviour - ie updating of the target element when the resource changes. tb

GestureService OnFlick

瘦欲@ 提交于 2019-11-29 17:05:06
How can I add the GestureService and a handler for the Flick event in code-behind (i.e. not in XAML)? Firstly, make sure you've added a reference to the Silverlight Toolkit for Windows Phone 7 , specifically the Microsoft.Phone.Controls.Toolkit.dll assembly. Then make sure you have an XML namespace reference for the Microsoft.Phone.Controls namespace: xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" Then, add the GestureService.GestureListener to the control you want to handle gestures on: <TextBlock x:Name="test" Text="Test"> <toolkit

C# code behind for Button Click Event, ASP.NET

独自空忆成欢 提交于 2019-11-29 10:57:37
I'm working with HTML provided by coworker in .aspx and I need to program in .aspx.cs(C#) the functionality of the button he created using HTML. The code I'm dealing with is as follows: </div> <button style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue">Ship</button> <button style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue">Rate</button> </div> I'm new to HTML but in looking at solutions to similar questions I often see the HTML code for a functional button looking more like <button type="submit" runat="server" id="btnLogin" class="button" onclick="btnLogin

binding to width property in code behind

大城市里の小女人 提交于 2019-11-29 10:55:52
I have a situation where I need to create View box with one button. The xaml for this is as below: Please observe Width property of viewbox. The Width should be increased/decreased according to a slider bar(moving to right increases it, to left decreases it). As listed below I know how to do it in xaml and it works fine. But my requirement is to be able to create viewbox in code behind and assign it the properties. <WrapPanel x:Name="_wrpImageButtons" Grid.IsSharedSizeScope="True" ScrollViewer.CanContentScroll="True" d:LayoutOverrides="Height" Margin="5"> <Viewbox x:Name="_ScaleButton" Width="

ASP.NET, VB: how to access controls inside a FormView from the code behind?

我怕爱的太早我们不能终老 提交于 2019-11-29 10:10:12
问题 I have a checkbox and a panel inside of a FormView control, and I need to access them from the code behind in order to use the checkbox to determine whether or not the panel is visible. This is the code that I originally used, but since I put the controls inside of the FormView, it no longer works. Protected Sub checkGenEd_CheckedChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) If checkGenEd.Checked = True Then panelOutcome.Visible = True Else panelOutcome.Visible = False End If

How to programmatically measure string pixel width in ASP.NET?

我的未来我决定 提交于 2019-11-29 10:01:32
How do you get the size of a string? In Windows Forms it's easy, I just use graphics object and then MeasureString function. In ASP.NET I'm not sure how to do this. Eystein Bye Like Tom Gullen is saying. You can just create a bitmap and messure the string. I have this code I use to find the width/length in pixel. Just change the font and size. // Bitmap class namespace: using System.Drawing; ... private float GetWidthOfString(string str) { Bitmap objBitmap = default(Bitmap); Graphics objGraphics = default(Graphics); objBitmap = new Bitmap(500, 200); objGraphics = Graphics.FromImage(objBitmap);

How do I add Page Events for ASP.NET in Visual Studio 2008

安稳与你 提交于 2019-11-29 03:06:14
问题 This is a bit of a Visual Studio question. I feel with all the helpful Intellisense there should be something to assist but I can't seem to find it. I made a page with a codebehind in ASP.NET C# in VS2008 and it autogenerates a PageLoad event method, of course. Well, what if I want to add methods for more events besides PageLoad? I would think there would be some list on the Foo.aspx page of possible method event handlers to add. Aren't there more maybe like PageInit, PageDispose, (or equiv)

In an ASP.NET website with a codebehind at what point are the .cs files compiled?

丶灬走出姿态 提交于 2019-11-29 02:30:48
问题 In Brief: In an ASP.net website with a code-behind, at what point are the *.cs files compiled? Context: A colleague who has since left, deployed a website with a .cs code-behind to a shared server. I have made a small change to a .cs file, which I should expect to reflect on one of the pages but it has not yet appeared. I have restarted the application pool, however I am loathe to reset IIS on the server as there are couple of other teams' apps which might be be in use on the same server. 回答1