Wednesday, June 30, 2010

getElementByID return always null calling from RegisterClientScriptBlock

Add  ClientScript.RegisterStartupScript instead of ClientScript.RegisterClientScriptBlock

Because>>>>>>>>>>>>>
The RegisterClientScriptBlock method inserts the client-side script immediately below the opening tag of the Page object's <form runat="server"> element. The code cannot access any of the form's elements because, at that time, the elements haven't been instantiated yet. This explains why hdnView variable had a null value in my case. The RegisterStartupScript method inserts the specified client-side script just before the closing tag of the Page object's <form runat="server"> element. The code can access any of the form's elements because, at that time, the elements have been instantiated. The choice of which method to use really depends on the "order" in which you want your script to be run by the browser when rendering the page.

Wednesday, June 23, 2010

Want to create an html link <a href=""></a> and Iframe using C# - dynamically

// Create a new HtmlAnchor control.
HtmlAnchor NewAnchorControl = new HtmlAnchor();

// Set the properties of the new HtmlAnchor control.
NewAnchorControl.Name = "NewAnchorControl";
NewAnchorControl.HRef = "http://www.microsoft.com";
NewAnchorControl.Target = "_blank";
NewAnchorControl.InnerHtml = "Microsoft Home";

// Add the new HtmlAnchor control to the Controls collection of the
// PlaceHolder control.
ControlContainer.Controls.Add(NewAnchorControl)

//Iframe
HtmlGenericControl frame1 = new HtmlGenericControl("iFrame");
frame1.Attributes.Add("runat", "server");
frame1.Attributes.Add("width", "100px");
frame1.Attributes.Add("height", "100px");
frame1.TagName = "iframe";
frame1.Attributes.Add("src", "http://www.microsoft.com");

ControlContainer.Controls.Add(frame1)

Wednesday, June 16, 2010

problem with RegisterClientScriptBlock in UpdatePanles

Error:::::
The script tag registered for type 'ASP.projectviewer_asp' and key ###### has invalid characters outside of the script tags: <link href='####.css' type='text/css' rel='stylesheet' >. Only properly formatted script tags can be registered.

This Work fine -------------
page.ClientScript.RegisterStartupScript( page.GetType(),"CSS", " <link href='####.css' type='text/css' rel='stylesheet' >", false);

Tuesday, June 15, 2010

The partner transaction manager has disabled its support for remote/network transactions

1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not running
If it is running and client application is not on the same computer as
the database server, on the computer running database server
1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers
> My Computer" (you may need to double click and wait as some nodes
need time to expand)
3. Right click on "My Computer", select "Properties"
4. Select "MSDTC" tab
5. Click "Security Configuration"
5 Select Network DTC Access, Allow Inbound, Allow Outbound, No Authentication Required, and Enable XA Transactions

Wednesday, June 9, 2010

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

We may get this error when trying to browse an asp.net application.

The debug information shows that "This error can be caused by a virtual directory not being configured as an application in IIS."

However, this error occurs primarily out of 2 scenarios.

1. When we create an new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if we manually create the virtual directory and it is not configured as an application, then we will not be able to browse the application and may get the above error. The debug information we get as mentioned above, is applicable to this scenario.

To resolve it, Right Click on the virtual directory - select properties and then click on
"Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.


2. When we have sub-directories in wer application, we can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (we may see that the error message shows the line number where the authentication or sessionstate is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point).

Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unathorized users).

But actually, this can be achieved in the web.config at the application's root level itself, by specifing the location path tags and authorization, as follows:-


<location path="Admin">


<system.web>


<authorization>


<allow roles="administrators" />


<deny users="*" />


</authorization>


</system.web>


</location>




However, if we wish to have a web.config at the sub-directory level and protect the sub-directory, we can just specify the Authorization mode as follows:-


<configuration>


<system.web>


<authorization>


<allow roles="administrators" />


<deny users="*" />


</authorization>


</system.web>


</configuration>

Wednesday, June 2, 2010

Change Theme Folder Style Sheet ASP.NET

01.Add New Style Sheet in to the theme folder.
02.Write Bellow Code in to the Code Behind.

string css = @"<link )="" +="" @="" app_themes="" blue="" css="" href="" rel="" stylesheet2.css="" stylesheet="" text="" this.resolveurl(="" type=""></link>";

ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "_calcss", css, false);


It Replace In .aspx Page Like>>>>>>>>>>>



<head><title>

</title><link href="App_Themes/Red/StyleSheet.css" type="text/css" rel="stylesheet" /><link href="App_Themes/Red/StyleSheet2.css" type="text/css" rel="stylesheet" /></head>

<body>
<form name="form1" method="post" action="WebForm1.aspx" id="form1">
<div>

</div>

<link href="/App_Themes/Blue/StyleSheet2.css" type="text/css" rel="stylesheet" />


Refer:http://www.west-wind.com/weblog/posts/158367.aspx

Tuesday, June 1, 2010

While Saving the excel using workbook.saveAs getting the Exception from HRESULT: 0x800A03EC 02-18-2010, 1:59 AM

1. Login to the server as a administrator. 
2. Go to "Start" -> "Run" and enter "taskmgr" 
3. Go to the process tab in task manager and check "Show Processes from all 
users" 
4. If there are any "Excel.exe" entries on the list, right click on the 
entry and select "End Process" 
5. Close task manager. 
6. Go to "Start" -> "Run" and enter "services.msc" 
7. Stop the service automating Excel if it is running. 
8. Go to "Start" -> "Run" and enter "dcomcnfg" 
9. This will bring up the component services window, expand out "Console 
Root" -> "Computers" -> "DCOM Config" 
10. Find "Microsoft Excel Application" in the list of components. 
11. Right click on the entry and select "Properties" 
12. Go to the "Identity" tab on the properties dialog. 
13. Select "The interactive user." 
14. Click the "OK" button. 
15. Switch to the services console 
16. Start the service automating Excel17. Test you application again.
 
If Not
my service starts under local Administrator account
- on DCOM Config > MS Excel Application > Identity tab I've selected "This 
user" option and also entered Administrator's account 

Opening Office filetype from within update panel causes Security bar to block files. [INTERNET EXPLORER]

To FIX THIS--------------------

1. From Internet Explorer, click Tools, and then click Internet Options. The Internet Options dialog box appears.
2. Click the Security tab. The Internet Options dialog box shows your security levels and zones.
3. Select the Internet zone, and then click Custom Level. The Security Settings dialog box appears.
4. Scroll down to Downloads, and then select the Enable option for Automatic prompting for file downloads.