ASP (Active Server Page)

What is the difference between static or dynamic assemblies?

Posted on

Assemblies can be static or dynamic.

Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files.

Dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.

What is a PostBack?

Posted on

The process in which a Web page sends data back to the same page on the server.

PostBack is the name given to the process of submitting an ASP.NET page to the server for processing. PostBack is done if certain credentials of the page are to be checked against some sources (such as verification of username and password using database). This is something that a client machine is not able to accomplish and thus these details have to be ‘posted back’ to the server.

AutoPostBack Property in ASP.NET:

If we create a web Page, which consists of one or more Web Controls that are configured to use AutoPostBack (Every Web controls will have their own AutoPostBack property), the ASP.Net adds a special JavaScipt function to the rendered HTML Page. This function is named _doPostBack() . When Called, it triggers a PostBack, sending data back to the web Server.

ASP.NET also adds two additional hidden input fields that are used to pass information back to the server. This information consists of ID of the Control that raised the event and any additional information if needed. These fields will empty initially as shown below,

<input type=”hidden” name=”__EVENTTARGET” id=”__EVENTTARGET” value=”” />
<input type=”hidden” name=”__EVENTARGUMENT” id=”__EVENTARGUMENT” value=”” />
    The _doPostBack() function has the responsibility for setting these values with the appropriate information about the event and the submitting the form. The _doPostBac
() function is shown below:
<script language=”text/javascript”>

function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();

    }
</script>

ASP.NET generates the _doPostBack() function automatically, provided at least one control on the page uses automatic postbacks.

Any Control that has its AutoPostBack Property set to true is connected to the _doPostBack() function using the onclick or onchange attributes. These attributes indicate what action should Browser take in response to the Client-Side javascript events onclick and onchange.

What is the difference between Server.Transfer and response.Redirect?

Posted on

The Server.Transfer () method stops the current page from executing, and runs the content on the specified page, when the execution is complete the control is passed back to the calling page.
While the Response.Redirect () method transfers the control on the specified page and the control is never passed back to calling page after execution.

What is reflection?

Posted on Updated on

All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection.
The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.

You can get this goal using ReflectionComponent in the App_Code folder by managing the parameter object that you pass when the static method ManagedControls.ChangeControlsAttributeValues is called. Let’s see how:

After you have selected areas, in “Enable by role”, select “Operator”. Note that each webcontrol in the controls container includes a custom attribute named Security. In this example, in the control, when the value of “Security” contains “Operator” the attribute “Enable” will be set to “true“.

<asp:Button ID="btnOne" runat="server" Security="Administrator;Operator;Other" Text="Button" Enabled="False" 
         OnClientClick="javascript:return false;"/>
<asp:Label ID="lblBtnOne" runat="server" Text="(Disabled)" ForeColor="Red"></asp:Label><br /><br />   

<asp:CheckBox ID="chkOne" runat="server" Security="Administrator;Operator" Text="CheckBox" Enabled="False"/>
<asp:Label ID="lblChkOne" runat="server" Text="(Disabled)" ForeColor="red"></asp:Label><br /><br />

<asp:TextBox ID="txtOne" runat="server" Security="Administrator" Enabled="False" ></asp:TextBox>
<asp:Label ID="lblTxtOne" runat="server" Text="(Disabled)" ForeColor="red"></asp:Label><br/><br/>

To get this goal you need to call the static method ManagedControls.ChangeControlsAttributeValues of the utility with the correct parameters. Look at the code in the ddlUserRoles_SelectedIndexChanged method.

_managedControlParameter = new ManagedControlParameter();

//Set container control
if (chklTemplate.Items[0].Selected)
    _managedControlParameter.MainControls.Add(Master);
if (chklTemplate.Items[1].Selected)
    _managedControlParameter.MainControls.Add(rightFieldset);
if (chklTemplate.Items[2].Selected)
    _managedControlParameter.MainControls.Add(firstUserControl);
if (chklTemplate.Items[3].Selected)
    _managedControlParameter.MainControls.Add(secondUserControl);

//Set type of control you want change property 
_managedControlParameter.ManagedControls.Add(ManagedControlType.All);

//Set property you want change if custom attribute (Security) is setting to correct value
_managedControlParameter.Attributes.Add(new ManagedControlTypeAttributesValue
                                            {
                                                Attribute = "Enabled",
                                                AttributeNewValue = "true",
                                                CustomAttribute = "Security",
                                                CustomAttributeValue = ddlUserRoles.SelectedValue
                                            });
//Call
ManagedControls.ChangeControlsAttributesValues(_managedControlParameter);

What is the difference between Classic ASP and ASP.Net?

Posted on

ASP

      is Interpreted language based on scripting languages like Jscript or VBScript.

    • ASP has Mixed HTML and coding logic.
    • Limited development and debugging tools available.
    • Limited OOPS support.
    • Limited session and application state management.

ASP.Net

    is supported by compiler and has compiled language support.

  • Separate code and design logic possible.
  • Variety of compilers and tools available including the Visual studio.Net.
  • Completely Object Oriented.
  • Complete session and application state management.
  • Full XML Support for easy data exchange.

Paypal Payment Option

Posted on

there is a sample paypal payment option we can make by following code .we can do it dynamic with any of the technology like php,jsp,asp.net,asp etc

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="PAYPAL EMAIL ADDRESS">
 <input type="hidden" name="lc" value="US">
 <input type="hidden" name="item_name" value="ITEM FOR SALE">
 <input type="hidden" name="amount" value="PRICE">
 <input type="hidden" name="currency_code" value="USD">
 <input type="hidden" name="button_subtype" value="products">
 <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"
 border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
 </form> 
Change the three bold items to your values, specifically:
  • PAYPAL EMAIL ADDRESS – the address you receive paypal funds from
  • ITEM FOR SALE – a short description or title of the item for sale
  • PRICE – Do not include the dollar-sign, and do include the pennies, even if it’s an even number (ie. 800.00 – not $800) The price will be in US dollars.
You can put that form on every page that you want to sell something, just change the price and description

What is ASP.net?

Posted on

After four years of development, and a series of beta releases in 2000 and 2001, ASP.NET 1.0 was released on January 5, 2002 as part of version 1.0 of the .NET Framework. Even prior to the release, dozens of books had been written about ASP.NET, and Microsoft promoted it heavily as part of its platform for Web services.

ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.

ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Framework. You can code your applications in any language compatible with the common language runtime (CLR), including Microsoft Visual Basic and C#. These languages enable you to develop ASP.NET applications that benefit from the common language runtime, type safety, inheritance, and so on.