Sunday, April 15, 2012

GET ALL CONTROL INSIDE FORM AND SET CONTROLS PROPERTY

Public Shared Function GetControls(ByVal form As Control) As List(Of Control)
Dim controlList = New List(Of Control)()
For Each childControl As Control In form.Controls
' Recurse child controls.
controlList.AddRange(GetControls(childControl))
controlList.Add(childControl)
Next
Return controlList
End Function


Private Sub SetControls(ByVal _controls As List(Of Control), ByRef dtControrName As DataTable)
Dim cControl As Control

For Each cControl In _controls
If (TypeOf cControl Is Button) Then

For i As Integer = 0 To dtControrName.Rows.Count - 1

If (cControl.Name = dtControrName.Rows(i)(0).ToString) Then
cControl.Enabled = True
Exit For
Else
cControl.Enabled = False
End If
Next
End If

Next cControl
End Sub


Dim controlList = New List(Of Control)()
controlList = GetControls(_form)//Parametar formname
SetControls(controlList, dtGET_FORM_PERMISSION)

Friday, April 13, 2012

Dynamic css file change

1. Create a html file

and put the codes




Dynamic css file changing







-A    A    A+
Soumen Ghosh





2. And create 3 css files with different font size and name them

"style1.css" write body { text-align: center; font-size:9px; }
"style2.css" write body { text-align: center; font-size:20px; }
"style3.css" write body { text-align: center; font-size:36px; }

Textbox eocus change on enter key press

Private Sub txtModiulname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtModiulname.KeyDown
If e.KeyCode = Keys.Enter Then
Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
End If
End Sub

Auto Clear Textbox Control

$(document).ready(function () {
  $('.autoclear').autoclear();
});

<form method="post">
  <label for="name">Name:</label><input type="text" id="name" name="name" title="John Smith" value="<?php echo $_POST['name']; ?>" class="autoclear"/>
  <label for="email">Email:</label><input type="text" id="email" name="email" title="your@yourdomain.com" value="<?php echo $_POST['email']; ?>" class="autoclear"/>
  <label for="about">About:</label><textarea id="about" name="about" title="Tell us a little bit about yourself..." class="autoclear"><?php echo $_POST['about']; ?>
  <input type="submit" value="Submit"/><input type="reset" value="Reset"/>
</form>

Wednesday, March 28, 2012

Make image proportionately small from url link asp.net

int width = 0;
int height = 0;

//
var webClient = new System.Net.WebClient();
byte[] image = webClient.DownloadData("http://static.livedemo00.template-help.com/wt_38438/images/page4_img2b.jpg");
//

//byte[] image = FileUpload1.FileBytes;

Int32.TryParse("100", out width);
Int32.TryParse("100", out height);
ImageHandler imageHandler = new ImageHandler();
bool maintainAR = true;
//calling CreateThumbnail Method to create thumb images
//it returns Bitmap Image.
Bitmap bmp = imageHandler.CreateThumbnail(image, maintainAR, width, height);
if (bmp != null)
{
//creating a file name with guid.
string fileName = Guid.NewGuid().ToString() + ".jpg";
//saving in current root folder.
bmp.Save(Server.MapPath(fileName));
//set image controls ImageUrl to saved Image, this is to view the thumbnail image
Image1.ImageUrl = fileName;
}
else
{
//exception part
if (imageHandler.havException)
{
Response.Write(imageHandler.ExceptionMessage);
}
}

Tuesday, March 27, 2012

Image upload through FCK editor - Solution

Steps to make it working.

1. Add





in web.config file.

this path represents the path you want are uploading the image

2. change

var _FileBrowserLanguage = 'aspx'; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'aspx'; // asp | aspx | cfm | lasso | perl | php | py

in fckconfig.js file. for .net only.

3. put the absolute path like

UserFilesAbsolutePath = "C:\\Users\\soumen\\Desktop\\web\\fckeditor\\editor\\images\\UserFilesUpload";


in connector.aspx under "\fckeditor\editor\filemanager\connectors\aspx"

Monday, March 19, 2012