Category Archives: ASP.NET

How to access ASP.NET Controls from code-behind inside a LoginView control

I almost created a completely new project as i thought it was one of those unexplained Visual Studio phenomenons. As a last measure I consulted Dr.Google and voila!

The following example holds true for any control, just make sure to add the corresponding attributes and values for casting.

(All codes in VB,NET)

To access a TextBox Control

Dim tbox As TextBox = DirectCast(LoginView1.FindControl("TextBox3"), TextBox)
tbox.Text = "WOW"

To access a Image Control

Dim picture As Image = DirectCast(LoginView1.FindControl("img1"), Image)
picture.ImageUrl = "pics/thumbs/what.png"

To access a Label Control

Dim labelname As Label = DirectCast(LoginView1.FindControl("label1"), Label)
labelname.Text ="last"
Advertisements
Tagged , ,

Visual Studio 2013: The System Cannot Find The File Specified. (Exception From HRESULT: 0x80070002)

I clicked Create New Project, and accepted all the defaults: New Project Application Defaults

However, immediately following pressing the Create Project button above, I get this message:

The system cannot find the file specified. (Exception from HRESULT: 0x80070002) Error message

To get this resolved you need to do the following:

  • Within VS, Tools > Extensions and Updates

VS-01

  • Expand Online and choose Visual Studio Gallery

VS-02

  • Search for NuGet Package Manager for Visual Studio

VS-03

  • Download and install
  • Restart VS

VS-04

  • Create your project and error will disappear and you will have files in the Solution Explorer

Via Just another IT blog

Tagged ,

Fixing the Telerik RadGrid Filter Case Sensitive Issue

By default the filter option for the RadGrid is set to be case-sensitive (true). You can change this on the .aspx page by specifying it tn the declaration of the grid.

GroupingSettings-CaseSensitive="False"
Tagged , ,

Reducing the Filter Menu Options in a Telerik RadGrid

You can reduce the filter menu options to display only a subset of the available filter functions. There are two possible approaches – client-side and server-side. I personally prefer the server-side approach and the following example shows how to reduce the set of filter functions so that the filter menu can only show the NoFilter, Contains, EqualTo, GreaterThan and LessThan items:

Private Sub RadGrid1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.Init
    Dim menu As GridFilterMenu = RadGrid1.FilterMenu
    Dim i As Integer = 0
    While i < menu.Items.Count
        If menu.Items(i).Text = "NoFilter" Or _
           menu.Items(i).Text = "Contains" Or _
           menu.Items(i).Text = "EqualTo" Or _
           menu.Items(i).Text = "GreaterThan" Or _
           menu.Items(i).Text = "LessThan" Then
            i = i + 1
        Else
            menu.Items.RemoveAt(i)
        End If
    End While
End Sub
Tagged ,

Check if an ASP.NET CheckBoxList items are Checked or Unchecked

The VB.NET code to check if an ASP.NET CheckBoxList items are Checked or Unchecked:

Dim i as integer

for i = 0 to checklistbox1.items.count -1
if checklistbox1.item(i).selected = false then
'do something here
else
'do something if they are checked.
end if
next

Tagged , ,

Hide an ASP.NET RadioButtonList using jQuery

$('#<%=rblSearchType.ClientID %>').hide();

Tagged , ,

Disable an ASP.NET RadioButtonList using jQuery

$("#<%=rblSearchType.ClientID%>").find('input').prop('disabled', 'true');

Tagged , ,