lundi 28 août 2017

Checkbox from datatable not handling checked event

In my page i am populating a GridView from code behind by setting the source a custom Datatable that i compile from an XML file, in this way i write the columns header and the rows title. And this works fine, so i am adding checkboxes in the cells while adding the columns in this way:

            DataTable dt = new DataTable();
        dt.Columns.Add(" ");
        foreach (XmlNode xns in doc.DocumentElement.ChildNodes[0])
        {
            foreach (XmlNode xn in xns)
            {
                string tagName = xn.Name;

                dt.Rows.Add(tagName);
            }

        } 

        dt.Columns.Add("Mattina Turno 1", typeof(bool)); //this adds the checkbox
        dt.Columns.Add("Mattina Turno 2", typeof(bool)); 
        dt.Columns.Add("Pomeriggio", typeof(bool)); 

        GridView1.DataSource = dt;
        GridView1.DataBind();

I am enabling each checkbox in my Gridview RowDataBound in this way:

 for (int i = 0; i < e.Row.Cells.Count;i++)
        {
            if (e.Row.Cells[i].GetType() == typeof(System.Web.UI.WebControls.DataControlFieldCell))
            {

            TableCell tc = e.Row.Cells[i];
            if (tc.Controls.Count > 0)
                {
                CheckBox cb = (CheckBox)tc.Controls[0];
                    if (cb != null)
                    { 
                        cb.Enabled = true;
                        colonna = ((GridView)sender).HeaderRow.Cells[i].Text;
                        riga = e.Row.Cells[0].Text;
                        cb.CausesValidation = false;
                        cb.ID = riga + " " + colonna;
                        cb.ToolTip = riga + " " + colonna;
                        cb.AutoPostBack = true; 
                        cb.CheckedChanged += new EventHandler(Cb_CheckedChanged);
                    } 

                    }  
                }
            }
        }

But when i try to handle the check event of the checkbox nothing happens. The checkchanged should call Cb_CheckedChanged but nothing happens.

this is Cb_CheckChanged:

        private void Cb_CheckedChanged(object sender, EventArgs e)
    {
        Cliccato.Text = ((CheckBox)sender).ID.ToString();
        System.Diagnostics.Debug.Write(((CheckBox)sender).ToolTip);
    }

Please Help me, i really need your help!




Why are public variables lost after an error?

I have developed the following two subs which create and remove a collection of checkboxes next to a listobject. Each distinct ID in the listobject gets a checkbox. Like this I can approve the listobject entries.

The code is the follwing:

Public CBcollection As Collection
Public CTRLcollection As Collection

Sub create_chbx()
If Approval.CBcollection Is Nothing Then
Dim i As Integer
Dim tbl As ListObject
Dim CTRL As Excel.OLEObject
Dim CB As MSForms.CheckBox
Dim sht As Worksheet
Dim L As Double, T As Double, H As Double, W As Double
Dim rng As Range
Dim ID As Long, oldID As Long

Set CBcollection = New Collection
Set CTRLcollection = New Collection
Set sht = ActiveSheet
Set tbl = sht.ListObjects("ApprovalTBL")
Set rng = tbl.Range(2, 1).Offset(0, -1)
      W = 10
      H = 10
      L = rng.Left + rng.Width / 2 - W / 2
      T = rng.Top + rng.Height / 2 - H / 2

For i = 1 To tbl.ListRows.count
      ID = tbl.Range(i + 1, 1).Value
      If Not (ID = oldID) Then
            Set CTRL = sht.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, DisplayAsIcon:=False, Left:=L, Top:=T, Width:=W, Height:=H)
            Set CB = CTRL.Object
            CBcollection.Add Item:=CB
            CTRLcollection.Add Item:=CTRL
      End If

      Set rng = rng.Offset(1, 0)
      T = rng.Top + rng.Height / 2 - H / 2
      oldID = ID
Next i
End If
End Sub


Sub remove_chbx()
If Not Approval.CBcollection Is Nothing Then
With Approval.CBcollection ' Approval is the module name
      While .count > 0
            .Remove (.count)
      Wend
End With
With Approval.CTRLcollection
      While .count > 0
            .Item(.count).Delete
            .Remove (.count)
      Wend
End With
Set Approval.CBcollection = Nothing
Set Approval.CTRLcollection = Nothing
End If
End Sub

This all works pretty well. No double checkboxes and no errors if there are no checkboxes. I am developing an approval scheme were I need to develop and test other modules. If I now run this sub:

Sub IdoStupidStuff()
Dim i As Integer
Dim Im As Image

i = 1
Set Im = i
End Sub

It will give me an error. If I then try to run one of my checkbox subs they will not work properly anymore. The collection is deleted by the error and I am no longer able to access the collections. Why does this happen and am I able to counter act this other then just not causing errors? Is there a better way to implement such a system were loss of collections is not an issue?




Wordpress checked current user

I am new in Wordpress.I want to current user checked in checkbox by default . How to do this. echo "";




dimanche 27 août 2017

how to get the value of checkbox which is inside the combo box WPF?

i have a combobox and the checkbox is present inside the combobox.i want the value of the multi selection checkbox.

my code-

    <ComboBox Name="LocationFilterComboBox" Width="100" SelectedItem="{Binding LocationValue}"  >
   <ComboBox.ItemTemplate >
 <DataTemplate>
<StackPanel Orientation="Horizontal" >
 <CheckBox Content="{Binding LocationValue}"  IsChecked="{Binding ElementName=all, Path=IsChecked, Mode=TwoWay}" Width="120" />
 </StackPanel>
</DataTemplate>
 </ComboBox.ItemTemplate>
</ComboBox>




How to unmark header checkbox on dataGridView after refreshing the data c#?

Header check box on selection select all the check boxes in the checkbox column. After selecting the header checkbox, when data refreshes, it is still displayed as marked on it.




PHP Radio Button Secure When Emailing

I've been trying to figure out if radio buttons and checkboxes need to be stripped (cleaned?) when sending them via email.

I have a contact form that just emails the information. It doesn't touch a database. Do I need to protect the radio buttons and checkboxes when emailing? Is it possible?

I haven't found anything on google regarding securing these when emailing them. I keep coming across a few answers that say that should definitely be protected when sending to a database. The same is found here, or questions regarding how to grab values or create one dynamically. So, I'm at a loss.

Do I secure radio buttons and checkboxes when emailing? Is it possible? Necessary? Here's what my code looks like, partially:

    $firstName = strip_tags($_POST['firstName']);
    $lastName = strip_tags($_POST['lastName']);
    $email = strip_tags($_POST['emailAddress']);
    $telNum = strip_tags($_POST['phoneNumber']);
    $colors= $_POST['eColors'];
    $additionalComments = strip_tags($_POST['additionalComments']);
    $spamField = strip_tags($_POST['sField']);


    <form id="contact-form" action="" method="post">

    <div>
            <input type="text" id="nameFirst" name="firstName" /> 
            <label for="nameFirst" class="nameIcon">
                <span>First Name</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="text" id="nameLast" name="lastName" />
            <label for="nameLast" class="nameIcon">
                <span>Last Name</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="email" id="eAddy" name="emailAddress" />
            <label for="eAddy" class="emailIcon">
                <span>Contact Email</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="tel" id="telNum" name="phoneNumber" />
            <label for="telNum" class="contactIcon">
                <span>Contact Number</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="checkbox" id="cbEColors" name="eColors" class="cbSwitch" />
            <label for="cbEColors">Do you expect more color?</label>
        </div>

        <div>
            <textarea id="addComments" name="additionalComments"></textarea>
            <label for="addComments" class="messageIcon">
                <span>Additional Comments</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <input type="text" id="sField" class="col" name="sField" />

        <button id="submit" name="submit" type="submit" value="Submit">Submit</button>

    </form>




How to change value of textbox when a checkbox is selected C# winforms

I have 1 label and 4 checkboxes. What I want to do is when a checkbox is selected I want the price to increase or decrease in the textbox depending on if the checkbox was unchecked or not. I am lost on how I can do that.

label is TextBlock_Price

checkboxes are the following: phScreenRepair, virusRemoval, hardwareRepInstall, softwareInstall My code:

     public float? MultipleServiceAdder()
    {
        if (phScreenRepair.Checked)
        {
            return 20.00f;
        }
        if (virusRemoval.Checked)
        {
            return 10.00f;
        }
        if (hardwareRepInstall.Checked)
        {
            return 10.00f;
        }
        if (softwareInstall.Checked)
        {
            return 5.00f;
        }
        textBlock_Price.Text = "$0.00";
        return 0f;
    }