This is a common problem in ASP.NET. It happens because some program is scanning the Temporary ASP.NET files folders where your assemblies are copied. They have the files open in a mode that prevents ASP.NET itself from using the assembly file.
You can set the EnableViewState property of the control. You should disable viewstate for any control that doesn’t use it to guarantee optimum performance.
Method 1. This will cause a postback on button click in response to which we will send some script to close the window.
VB.NET
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write('<script>window.close();</script>')
End Sub
Method 2. This is preferable since there is no postback involved.
Use the Attribute collections i.e useAttributesof button control toaddclient side JavaScript code
VB.NET
Button1.Attributes.Add('OnClick', 'window.close();')
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
’ Put user code to initialize the page here
IfNot Page.IsPostBack Then
Button1.Style.Add('LEFT', '1px')
EndIfEnd Sub ’Page_Load
Private Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
Button1.Style.Add('LEFT', RadioButtonList1.SelectedItem.Value.ToString())
End Sub ’RadioButtonList1_SelectedIndexChanged
C#
privatevoidPage_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page hereif (!Page.IsPostBack )
{
Button1.Style.Add('LEFT', '1px');
}
}
privatevoidRadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Button1.Style.Add('LEFT',RadioButtonList1.SelectedItem.Value.ToString());
}
ProtectedFunction createStyleForControl(ByVal _forecolor As Color, ByVal _backcolor As Color, ByVal _fontbold As Boolean) As StyleDims As Style = New Styles.ForeColor = _forecolors.BackColor = _backcolors.Font.Bold = _fontboldReturnsEndFunction
In Page_Load
Dim textboxStyle As Style = createStyleForControl(Color.Pink, Color.Yellow, False)
Dim buttonStyle As Style = createStyleForControl(Color.Blue, Color.Teal, True)
Dim checkboxStyle As Style = createStyleForControl(Color.AliceBlue, Color.PowderBlue, False)
TextBox1.ApplyStyle(textboxStyle)
Button1.ApplyStyle(buttonStyle)
CheckBox1.ApplyStyle(checkboxStyle)
Pseudo-elements are fictional elements that do not exist in HTML. They address the element’s sub-part. There are 2 types of pseudo-elements as “first-line pseudo-element’ and ’first-letter pseudo-element’. Pseudo-element is created by a colon followed by pseudo-element’s name,e.g:
P:first-lineH1:first-letter
and can be combined with normal classes;
e.g:
P.initial:first-line
The first line of this paragraph will be displayed in uppercase letters
User Controls are text files with the extension ’.ascx’ which enables you to make GUI re-usable controls. Its a text file, which contains a mixture of HTML and scripting. User Controls can be edited in an editor.
On the other hand Custom Controls reside in compiled ( Dll ) assemblies. They are non-GUI but can emit HTML GUI at runtime. Example of Custom Controls would be the sever controls which come bundled with the .NET SDK like DataGrid, Repeater, DataList etc. Custom Controls are always compiled into Dll’s and hence require good programming knowledge. The purpose of Custom Controls is also to create re-usable units of code.
Check out Jim Ross’s article Maintain Scroll Position in any Page Element The article describes, when using a scrollable Datagrid–one inside an overflow-auto DIV control–how to maintain the user’s scroll position inside the DIV across postbacks. It does this using IE behaviors, HTC files.
Dim x AsNew Unit('80px')
Dim y AsNew Unit('20px')
Dim imagestate as string= 'stand'If imagestate = 'stand' then
imagebutton1.height = x
else
imagebutton1.height = y
end if
C#
Unit x = new Unit ('80px');
Unit y = new Unit('20px');
string imagestate='stand';
if( imagestate != 'stand')
{
ImageButton1.Height = x;
}
else
{
ImageButton1.Height = y;
}
<asp:textboxid='TextBox1'runat='server'></asp:textbox><asp:rangevalidatorid='RangeValidator1'type='Date'controltovalidate='TextBox1'runat='server'errormessage='Not in range' /><asp:buttonid='Button1'runat='server'text='Button'></asp:button>
VB.NET
...
Dim dtMinDate As DateTime
Dim dtMaxDate As DateTime
dtMinDate = Convert.ToDateTime('04/25/04')
dtMaxDate = Convert.ToDateTime('10/17/04')
RangeValidator1.MinimumValue = dtMinDate
RangeValidator1.MaximumValue = dtMaxDate
TextBox1.Text = dtMaxDate.ToShortDateString
RangeValidator1.ErrorMessage = 'Not in Range of ' & dtMinDate.ToShortDateString() & ' to ' & dtMaxDate.ToShortDateString()
C#
DateTime dtMinDate ;
DateTime dtMaxDate ;
dtMinDate = Convert.ToDateTime('04/25/04');
dtMaxDate = Convert.ToDateTime('10/17/04');
RangeValidator1.MinimumValue = dtMinDate.ToShortDateString () ;
RangeValidator1.MaximumValue = dtMaxDate.ToShortDateString () ;
TextBox1.Text = dtMaxDate.ToShortDateString();
RangeValidator1.ErrorMessage = 'Not in Range of ' + dtMinDate.ToShortDateString() + ' to ' + dtMaxDate.ToShortDateString();
You can use Panel controls, which render as HTML div elements. You can then show or hide the panels by enabling/disabling them. In addition, you can specify different formatting options for different Panels/divs using manual formatting or CSS styles.
Dim i As Integer = 1
’Textbox
Dim txtBox As TextBox = New TextBox
txtBox.ControlStyle.CssClass = 'textbox'
txtBox.ID = 'txtbox' + i.ToString()
’RequiredFieldValidator
Dim rqdVal As RequiredFieldValidator = New RequiredFieldValidator
rqdVal.ID = 'rqdVal' + i.ToString()
rqdVal.ControlToValidate = 'txtbox' + i.ToString()
rqdVal.ErrorMessage = 'Please enter a value'
rqdVal.Display = ValidatorDisplay.Dynamic
’RangeValidator
Dim rngVal As RangeValidator = New RangeValidator
rngVal.ID = 'rngVal' + i.ToString()
rngVal.MinimumValue = '1'
rngVal.MaximumValue = '100'
rngVal.ControlToValidate = 'txtbox' + i.ToString()
rngVal.Type = ValidationDataType.Double
rngVal.ErrorMessage = ' Value should be between 1 and 100'
’Add Controls on the page
Page.Controls(1).Controls.Add(txtBox)
Page.Controls(1).Controls.Add(rqdVal)
Page.Controls(1).Controls.Add(rngVal)
C#
int i=1;
//Textbox
TextBox txtBox = new TextBox();
txtBox.ControlStyle.CssClass = 'textbox';
txtBox.ID = 'txtbox' + i.ToString();
//RequiredFieldValidator
RequiredFieldValidator rqdVal = new RequiredFieldValidator();
rqdVal.ID = 'rqdVal' + i.ToString();
rqdVal.ControlToValidate = 'txtbox' + i.ToString();
rqdVal.ErrorMessage = 'Please enter a value';
rqdVal.Display =ValidatorDisplay.Dynamic;
//RangeValidator
RangeValidator rngVal = new RangeValidator();
rngVal.ID = 'rngVal' + i.ToString();
rngVal.MinimumValue = '1';
rngVal.MaximumValue = '100';
rngVal.ControlToValidate = 'txtbox' + i.ToString();
rngVal.Type = ValidationDataType.Double;
rngVal.ErrorMessage = ' Value should be between 1 and 100';
//Add Controls on the page
Page.Controls[1].Controls.Add (txtBox);
Page.Controls[1].Controls.Add (rqdVal);
Page.Controls[1].Controls.Add (rngVal);