PDA

View Full Version : [CLOSED] Trouble setting checkbox from code behind to checked



tMp
Sep 06, 2013, 10:03 AM
Hi

It looks so simple that I am sure that I overlooked something important but I can't find it and it is bugging me for days without having found a solution on the web.

I just want to get that checkbox checked through code behind.

aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demo.aspx.cs" Inherits="demo" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="Form" runat="server">

<ext:ResourceManager ID="ResourceManager" runat="server" />

<ext:Button runat ="server" OnClientClick="App.direct.onButtonClick()" Text="Open window" />
</form>
</body>
</html>

cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

public partial class demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{

}
}

// On button click open window with checked checkbox
[DirectMethod]
public void onButtonClick()
{
Window win = new Window
{
Title = "Demo",
Items = { new Checkbox { FieldLabel = "checkbox", Checked = true } }
};

win.Render(this.Form);
}
}

Thank you very much.

Daniil
Sep 06, 2013, 12:32 PM
Hi @tMp,

Yes, that is a known problem.
https://github.com/extnet/Ext.NET/issues/251

Please set up this setting for the Checkbox to get rid off the problem.

IsDynamic = true

tMp
Sep 06, 2013, 2:38 PM
Thank you. Working perfectly like this. Sorry that I didn't find this myself.

Daniil
Sep 06, 2013, 3:07 PM
You are good. When I faced this issue first time, I spent quite a lot of time to sort it out. Ideally, it should not require that IsDynamic setting, but we were unable to come up with better solution.