Forum Discussion
jaakivask
Jul 12, 2023Copper Contributor
Trouble with WebForms app
Hello, I do not have access to the code-behind source file. This file is not existing in the deployed app. The aspx file contains next code fragment (this is working correctly), but very long...
AddWebSolution
Dec 08, 2023Brass Contributor
Hi jaakivask,
In a WebForms application, you can declare and use variables in the code-behind file associated with the corresponding .aspx page. Since you mentioned that you do not have access to the code-behind source file, you may face limitations in making such changes. However, I'll provide guidance on where you would typically declare a variable in the code-behind file.
Locate the Code-Behind File:
The code-behind file is associated with the .aspx page and usually has the same name as the .aspx page with a ".aspx.cs" or ".aspx.vb" extension for C# or VB.NET, respectively.
Add a Variable Declaration:
Open the code-behind file in a code editor.
Inside the class associated with the .aspx page, you can declare a variable. For example, you can declare the variable at the class level to make it accessible throughout the class.
public partial class YourPageName : System.Web.UI.Page
{
// Declare a variable at the class level
private string productVariantName;
// Other code...
// Event handler or method where you want to assign a value to the variable
protected void Page_Load(object sender, EventArgs e)
{
// Assign a value to the variable
productVariantName = ((OrderProductVariant)Container.DataItem).ProductVariant.Name;
// Other code...
}
// Other methods or event handlers...
}
Use the Variable in Your Markup:
Once the variable is declared at the class level, you can use it in your markup within the .aspx file.
<p style="font-family:Arial;font-size: 9pt;color:black" class="bla">
<%# ProductService.GetProductVariantName((OrderProductVariant)Container.DataItem, LanguageId) %>
<strong>
<%# (productVariantName == "Kuldne keskmine" || productVariantName == "Aukso vidurys") && ((OrderProductVariant)Container.DataItem).ProductVariant.Product.TemplateId == 4 ? "GĖLIŲ VAZA" :
(productVariantName == "Luksuslik" || productVariantName == "Deluxe") && ((OrderProductVariant)Container.DataItem).ProductVariant.Product.TemplateId == 4 ? "GĖLIŲ VAZA" : "" %>
</strong>
</p>
Remember to replace "YourPageName" with the actual name of your .aspx page, and make sure to save your changes and recompile the application. If you don't have access to the code-behind file, you might need to work with the development team or the person responsible for maintaining the code to make these modifications.
Here you can refer the link also
https://stackoverflow.com/questions/4029467/broken-link-between-aspx-and-aspx-cs-files
Thanks & Best Regards,
AddWebSolution
In a WebForms application, you can declare and use variables in the code-behind file associated with the corresponding .aspx page. Since you mentioned that you do not have access to the code-behind source file, you may face limitations in making such changes. However, I'll provide guidance on where you would typically declare a variable in the code-behind file.
Locate the Code-Behind File:
The code-behind file is associated with the .aspx page and usually has the same name as the .aspx page with a ".aspx.cs" or ".aspx.vb" extension for C# or VB.NET, respectively.
Add a Variable Declaration:
Open the code-behind file in a code editor.
Inside the class associated with the .aspx page, you can declare a variable. For example, you can declare the variable at the class level to make it accessible throughout the class.
public partial class YourPageName : System.Web.UI.Page
{
// Declare a variable at the class level
private string productVariantName;
// Other code...
// Event handler or method where you want to assign a value to the variable
protected void Page_Load(object sender, EventArgs e)
{
// Assign a value to the variable
productVariantName = ((OrderProductVariant)Container.DataItem).ProductVariant.Name;
// Other code...
}
// Other methods or event handlers...
}
Use the Variable in Your Markup:
Once the variable is declared at the class level, you can use it in your markup within the .aspx file.
<p style="font-family:Arial;font-size: 9pt;color:black" class="bla">
<%# ProductService.GetProductVariantName((OrderProductVariant)Container.DataItem, LanguageId) %>
<strong>
<%# (productVariantName == "Kuldne keskmine" || productVariantName == "Aukso vidurys") && ((OrderProductVariant)Container.DataItem).ProductVariant.Product.TemplateId == 4 ? "GĖLIŲ VAZA" :
(productVariantName == "Luksuslik" || productVariantName == "Deluxe") && ((OrderProductVariant)Container.DataItem).ProductVariant.Product.TemplateId == 4 ? "GĖLIŲ VAZA" : "" %>
</strong>
</p>
Remember to replace "YourPageName" with the actual name of your .aspx page, and make sure to save your changes and recompile the application. If you don't have access to the code-behind file, you might need to work with the development team or the person responsible for maintaining the code to make these modifications.
Here you can refer the link also
https://stackoverflow.com/questions/4029467/broken-link-between-aspx-and-aspx-cs-files
Thanks & Best Regards,
AddWebSolution