Dim script As String = "[Javascript function or in-line code goes here]"Page.RegisterClientScriptBlock("[Any name]", script)
Hung Nguyen
My Own World
Wednesday, March 10, 2010
Call Javascript from ASP.Net code behind
This is a very simple code on ASP.Net code behind to call a pre-defined Javascript function on client side or in-line Javascript.
Friday, November 7, 2008
Eval vs. Bind
The Bind keyword works like Eval to display data and can retrieve the value you've entered when updating or inserting a record. In addition, Bind is very useful in TemplateFields used in the GridView and DetailsView. Bind stores the value of the bound control property into a collection of values that the FormView control automatically retrieves and uses to compose the parameter list of the insert or edit command. The argument passed to Bind must match the name of a field in the data container.
The .NET Framwork 2.0 introduces Eval(). Eval() is a shortcut for Container.DataItem() (or DataBinder.Eval() in .Net Framework 1.1). Since Eval() uses Reflection, it causes overhead. From a optimization standpoint, it is better to use Container.DataItem().
Note: If you use Eval in the edit item template, the Eval-ed value will not be able to be passed to the Update method of the datasource.
Format Binding Field
I'm new to ASP.net and get the problem with formatting a binding to an expected format, like a culture date. Here is what I found and wanna post here not only for my later usage but also for whoever gets the same problem.
<asp:label runat="server" id="lblTimeLine" text="'<%#Bind("time_line", "{0:dd/MM/yyyy}")%/>
Saturday, October 25, 2008
0x80070032 - HTTP Error 404.3 - Not Found
If you recently install and run your ASP.Net application on your server (any server like localhost) and get Error Code 0x80070032 as below:
Error Summary
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Error Code: 0x80070032
Notification: ExecuteRequest
HandlerModule: StaticFile
ModuleRequested URL: http://localhost:80/ets/bob.asp
Physical Path: C:\inetpub\wwwroot\ets\bob.asp
Logon User: AnonymousLogon
Method: AnonymousHandler: StaticFile
How to fix it
On my case, it was because ASP.Net on IIS was not installed.
Open your Windows Features and check if you have following items are installed:
> Internet Information Services
+---> World Wide Web Services
+-------> Application Development Features
+-----------> ASP.Net
After installing it, your ASP.Net will run promtly.
Error Summary
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Error Code: 0x80070032
Notification: ExecuteRequest
HandlerModule: StaticFile
ModuleRequested URL: http://localhost:80/ets/bob.asp
Physical Path: C:\inetpub\wwwroot\ets\bob.asp
Logon User: AnonymousLogon
Method: AnonymousHandler: StaticFile
How to fix it
On my case, it was because ASP.Net on IIS was not installed.
Open your Windows Features and check if you have following items are installed:
> Internet Information Services
+---> World Wide Web Services
+-------> Application Development Features
+-----------> ASP.Net
![]() |
From Gogo Dude |
After installing it, your ASP.Net will run promtly.
Sunday, September 28, 2008
Error OnStart an Windows Service
If you recently get the following error when starting a service.
EventType clr20r3, P1 [application name].exe, P2 1.0.0.29354, P3 487d2235, P4 [application name], P5 1.0.0.29354, P6 487d2235, P7 38, P8 1, P9 system.typeinitialization, P10 NIL.
I got the solution. We should put a try/catch on static method, especially on [any]appsetting.cs if you call any its properties on Start method. On our own app.config loading method, we do have the way to through an exception (ex: when empty or invalid), but our exception does not sink to the outer exception wrapper then Windows thinks that is an unhandled exception and records the following error in Event Viewer which causes a headache when trying to figure out what the real error is.
System.Web.HttpException: Maximum request length exceeded.
If you recently got following error when calling any method to upload loan package to server:
System.Web.HttpException: Maximum request length exceeded.
This is because the default maximum HTTP request if not set is 4MB (4096). If you want to upload more than that, you must modify element in section
System.Web.HttpException: Maximum request length exceeded.
This is because the default maximum HTTP request if not set is 4MB (4096). If you want to upload more than that, you must modify element
<snip>
<system.web>
...
<httpruntime maxrequestlength="[maximum length (ex: 15360 = 15(MB) x 1024]">
...
</httpruntime>
</system.web>
</snip> On machine.config if you want all your applications on IIS have the same configuration.
Or on web.config if you want only the modified application is affected by the new policy.
Subscribe to:
Posts (Atom)