Questions tagged [code-behind]
Code-behind refers to code for your UI (Windows Forms, ASP.NET page, etc.) contained within a separate class file. This allows separation of the UI and the logic behind it.
1,954
questions
0
votes
1
answer
40
views
How to change the text of a textblock based on the selection of a combobox, both created dynamically? [closed]
My code creates dynamically a combobox with differents items and it sets it's price in a textbox. However, if I change the sselection of the combobox it doesn't change the price in the textbox. Do you ...
0
votes
0
answers
71
views
Programmatically Built Buttons Don't Appear in MainWindow
Background
I have an MVVM skeleton for a Risk game learning project. I have decided to attempt creating parts of the UI programmatically for both "convenience"/elegance and as a learning ...
1
vote
1
answer
19
views
VBnet on button_click need to run codebehind function then open modal dialog
I have an application where gridview data is selected and when finished, the user clicks a button to proceed. At that point I need to run a function in codebehind to process the selected items. Once ...
0
votes
2
answers
113
views
How to bind a style to a control in a View's code-behind?
I have some styles and I want to set them in the code-behind of my View.
How can I bind them in C#?
My Styles:
<ContentPage.Resources>
<Style x:Key="choosenButton" TargetType=&...
0
votes
1
answer
71
views
How to intelligently create and debug complex Maui Data Bindings for nested Stack Layouts?
I've been trying to create a Data Binding that would access a value from a parent Stack Layout.
I created a converter figuring that this would give me some visibility as to what my binding was doing.
...
0
votes
2
answers
90
views
Data Bind InvHeader/InvItems using Maui XAML in nested StackLayout where InvHeader.CustId = InvItem.CustId?
I'm trying to create a master/detail page in Maui. Just like an invoice with invoice items, this page must display sever 'invoices' each with their own invoice items.
Let's say we have a list of ...
0
votes
3
answers
64
views
How to Share Code Between Multiple Pages and Classes
Forgive me if I'm doing this wrong according to forum's rules, but I wasn't sure how to. This is a revision of the question asked at the link below. There was a response there that was close to an ...
0
votes
1
answer
55
views
How to Share Code Between Pages and Classes
This seems like it should be simple, but I cannot figure this out. I'm trying to share code between a Code Behind Page and a Class that inherits the Page class.
An important note is that I need the ...
0
votes
2
answers
95
views
Activate CharactersValidationBehavior after a Button was clicked
how is it possible to activate or re-evaluate the result of a CharactersValidationBehavior, which was set for an Entry, just after a Button was clicked?
<Entry.Behaviors>
<toolkit:...
0
votes
2
answers
74
views
How to programmatically bind to property of passed in object
I've been trying to bind the source, row, and column properties of a newly generated image to some value on an object on my viewmodel. Ideally, this could be solved by binding to the properties of the ...
1
vote
1
answer
47
views
Changing mouse over Foreground color of controls inside a Button in code behind
I've got this bit of XAML code. What it does is override the style of a button when mousing over. Here I use Green and PaleGreen for the sake of simplicity.
<Style TargetType="Button" x:...
1
vote
1
answer
516
views
Setup correctly a razor page to have access to data in code-behind
I'm new with Razor Pages and I found out that code can be divided using code-behind file. So I created this Index class to initialize my date and print them to the .cshtml file. But when I try to ...
0
votes
0
answers
18
views
Remove Span's Class from CodeBehind
I have the following code in an ascx file.
<table class="DetailsTable" id="tblEdit" runat="server">
<tr>
...
2
votes
0
answers
81
views
Why does Binding with RelativeSource doesn't work from code-behind in design-time?
I am trying to make short version of my binding markup by creating class inherited from Binding and setting all properties in constructor. This is simplified version of how original markup looks like (...
0
votes
0
answers
9
views
changing a rows backrow color in grid view based on the value of a field
How can I set the back color of a row in asp gridview based on the value of a field in the row?
I gave tried variations of the following code:
Sub ongridviewrowdatabound_gvBudgetView(ByVal o As ...
0
votes
0
answers
81
views
Sample Xamarin.Forms Project Without Using XAML
Late to the party and new to Xamarin.Forms. I'm looking for an example Xamarin.Forms app (sample code) which does not use any XAML, or, as little as possible. This is because I'm translating from an ...
1
vote
1
answer
160
views
.NET MAUI 7 - SwipeView inaccessible in code-behind
The SwipeView is in a CollectionView, that is accessible via its x:Name attribute. But I cannot access the SwipeView via its x:Name:
<SwipeView x:Name="swipe">
<SwipeView....
-1
votes
1
answer
33
views
Calculate relative position in Code Behind WPF
How can I calculate relative position of my elements (Lift, LArmPosition, PArmPosition) in code behind, where their position depends on the Canvas Width(X) and Height(Y) and the Width(X) and Height(Y) ...
0
votes
0
answers
29
views
I’m using MAUI and C#. How do I set x:name of a checkbox in the code-behind? [duplicate]
I am dynamically creating a list of checkboxes in the code-behind, based on the files I have in a specified directory.
I wish the set the x:Name of the checkbox to the name of its associated file or ...
0
votes
0
answers
25
views
Pasting value using jquery into .NET Textbox is showing the value but not saving
I am pasting the value in the .NET Textbox WebApplication (WebForm) using the javascript, and the value is also appearing in the textbox on the webpage upon pasting.
Textbox:
<asp:TextBox ID="...
0
votes
1
answer
279
views
Showing modal popup extender on click of a link that's in a table
I have a table of users (and their info). I want to have a link so they could edit any given user. I realized that I couldn't use asp:button and asp:hyperlink controls because those controls won't ...
-2
votes
1
answer
46
views
Textbox style setter breaks functionality
for some reason in my code behind (WPF), the "setter" section makes the text box not function anymore. I can't type in it or add any functionality to it. When I remove the setter section, ...
-2
votes
1
answer
51
views
.NET 6 WPF Can't change opacity in code behhind? [duplicate]
I've been trying to change the opacity of my window through code for a while now but I've had no success. I'm changing the Window.Opacity number in my function but I've had no results. As of now, I've ...
0
votes
0
answers
1k
views
.NET MAUI GestureRecognizer Tapped vs Command
Lets say I have a ListView whose DataTemplate is a Grid. On the Grid I have a GestureRecognizer
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped&...
0
votes
1
answer
132
views
Simple update query caused System.ComponentModel.Win32Exception: The wait operation timed out error in C# and SQL Server
I'm trying to create a Forgot password page, that verify the user's username, email, security question and answer, before sending them to the new password page. The code below is the onClick that ...
0
votes
1
answer
83
views
KeyBinding to a function in code behind? WPF/MVVM
I have a TextBox, when user presses Enter on their keyboard the value in textbox gets "confirmed" and the string is formatted to the correct amount of decimals.
So if the textbox should have ...
0
votes
1
answer
321
views
asp.NET Web App, how do I share classes with all code-behind files?
I know that super-basic newbie questions aren't always welcomed on this site, and I'm afraid that the mods might swoop down on this post like a hawk on a hamster, but I'm really stuck.
I inherited an ...
0
votes
0
answers
40
views
Jquery dialog text doesn't read html when generated from code behind
In our project we are calling dialog boxes two ways. For the ones with static text and buttons we generate the dialog in a script and get the text from hidden spans in front-end. When using html ...
0
votes
0
answers
181
views
Return value from controller to code behind blazor page
I have the following controller:
// Multiple files upload
[HttpPost("upload/multiple")]
public IActionResult Multiple(IFormFile[] files)
{
try
...
0
votes
0
answers
95
views
Concept of ADO.NET classes object binding with SQL Server stored procedure
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("user_storedproc_name", conn))
{
cmd.CommandType = ...
1
vote
1
answer
315
views
Is there a way to use variables to control the ID of html tags for a code-behind page in VB.NET?
I'm making a simple form. I have Default.aspx, Default.aspx.vb, and Default.aspx.designer.vb.
Default.aspx.vb contains a Public jsonItems As List(Of JsonItem), where a JsonItem is just an object with ...
0
votes
1
answer
173
views
element defined in xaml "does not exist" in c# code behind
I´ve started to learn xamarin forms and now I'm already starting to apply animation to my Image. But I've got an error in my code.
Here's my code in xaml.cs:
using System;
using System.Collections....
0
votes
0
answers
136
views
How do I call an async dependency service from my xaml.cs code behind?
I am overriding the OnBackButtonPressed() event in my code-behind because I add some custom navigation behaviour.
My target is to call a function from my bluetooth classic dependency service (...
0
votes
0
answers
20
views
variable between 2 pages (aspx.cs)
I have a form page with a button
When i click the button different stuff happens
At the end im showing another page as popup
i want to show variables in the pop-up from the first page and when the pop-...
0
votes
1
answer
651
views
How to change the text of a textbox in asp.net from code-behind
I'm trying to change the text of a textbox to increase by 1 after I click a button.
When I use this,
txtcounter.Text = txtcounter.Text + 1
The value increase by 1 but, it changes back to its original ...
0
votes
2
answers
866
views
(ASP.NET) Changing an input at the start of Page_Load() and then retriving the input value after form submit gives the old value
I have a form that is supposed to have defalt values, which the user can decide to change in some fields. The inputs are set up like this:
<input type="text" id="username" ...
0
votes
1
answer
121
views
Opening a popup by calling Javascript from CodeBehind
I am trying to open a popup window by calling a JavaScript function in CodeBehind (vb.net) on a button click event.
The idea is that I click the button, the button click event does a bunch of stuff, ...
0
votes
1
answer
46
views
C# User Control (MVVM) surface a property in MV
I feel though i may be missing somethig here, or its not doable (which i find hard to belive).
I have a UserControl thats using MVVM archtitecture.
The UserControl looks like this.
public partial ...
0
votes
1
answer
39
views
Complie error CS0103 after converting website to webapplication
I have an old website project that I am attempting to convert to a web application. After doing the conversion, I am receiving CS0103 errors. Here is the web page code:
<%@ Page Language="C#&...
0
votes
1
answer
206
views
Is there a way to assign a dynamic resource to a dependency property in code
I have a SolidColorBrush defined in a Resource Dictionary as follows:
<Color x:Key="ColorGray100">#F5F6F7</Color>
<SolidColorBrush x:Key="BrushGray100" Color=&...
1
vote
0
answers
55
views
ASP .net Datagrid Dynamic (OnRowDataBound) find all cell by label display diverentz by collor
I have a special thing to solve and can find a solution.
The Datagrid is bound to SQL query and has dynamic inner Join that is detectable all-time changing. The user can select any imported Data to ...
0
votes
1
answer
140
views
Visual Studio message: The document item has no code-behind file. (Building GUI for Powershell)
In Visual Studio, I created a new PowerShell Script Project to build a GUI for a script. Its something simple for now to moreso understand the concept of how this would work.
In the GUI I want to ...
0
votes
1
answer
159
views
Programmatically binding ComboBox
The task is a DataGrid with an unknown number of columns and rows. One column contains textbox, checkbox, imagebutton "Image-ComboBox" and "Text-Combobox" (both non-editable). ...
0
votes
1
answer
92
views
Why does the crystal reports engine appear to behave differently when used in a background task started using QueueBackgroundWorkItem?
In a web application I have code to generate a PDF file using crystal reports and both the ReportDocument.ExportToDisk and ReportDocument.ExportToStream methods. I am using the 64bit crystal runtime ...
0
votes
1
answer
449
views
Binding List<List<object>> to DataGrid columns in code-behind
I have a problem binding List<List> to DataGrid columns in code-behind.
Here is my list of lists:
private List<List<object>> matrix = new List<List<object>>()
{
...
0
votes
0
answers
333
views
Signature Pad Using C# Code Behind Will Not Allow Signature Insertion
@szimek I am trying to implement your Signature Pad in a C# Web Forms application. The signature pad displays and the Clear button is clickable, but the canvas won't open up to allow entry of the ...
0
votes
0
answers
522
views
WPF Expander usage inside DataGrid with code behind
I am trying to understand logic behind XAML in Expander control inside DataGrid. First I created this code in XAML inside the DataGrid and it works fine.
<DataGrid.GroupStyle>
...
0
votes
1
answer
550
views
Conditional text in Xamarin Forms
How do I conditionally render a particular text in Xamarin Forms 5?
For example, I get some data from my API backend for a vendor and there may be an address in the database for this vendor or not.
If ...
0
votes
1
answer
268
views
With a NavigationView control, how can I navigate from the code behind?
is it possible to navigate from code-behind in a NavigationView?
If I am one one page in the NavigationView's frame, and I want to leave that page and display another valid page, is this possible. My ...
0
votes
1
answer
397
views
C# WinUI 3 Get CS0053 error Inconsistent accessibility: property type 'INavigation' is less accessible than property 'App.Navigation'
Attempting to implement NavigationView navigation via code-behind using this solution I found:
https://xamlbrewer.wordpress.com/2021/07/06/navigating-in-a-winui-3-desktop-application/
I don't know ...