Saturday, September 27, 2008

ASP.NET: How to call webservice with parameters through extJs HttpProxy class.

In this post I am going to explain how we can call a C# asp.net webservice with parameters through extJs HttpProxy class.

You have to do this:

var storeName = new Ext.data.Store

({

proxy: new Ext.data.HttpProxy

({

url: 'webserviceName/methodName,

method: 'POST'

}),

baseParams: {parameter1: p1,parameter2 p2},

reader: readerName,

});

In webservice you have to write:

[WebMethod]

[ScriptMethod(ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]

public void GetData(int p1, int p2)

{

// outString is a JSON formated string

Context.Response.Write(outString);

}

Secure file download in Asp .net

I was trying my hands on Asp .net after a long time, and then came across an interesting problem. I was trying to write a function to make a secure download of web based files, that is I was trying to hide the path of file from user, who is going to download a file from my site. I googled a lot, but could not find the exact thing, that I was looking for. Then I collected the pieces of codes from my search, and created that function out of it. This function can be called from any event and will initiate the download without letting users know the path of target file.

The code goes here:

public void download(string fileName, string parentDirectory)
{
string path = Server.MapPath(pare);
FileInfo f1 = new FileInfo(path + "/" + fileName);
        if (f1.Exists)
        {
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + f1.Name);
            Response.AddHeader("Content-Length", f1.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(f1.FullName);
            Response.End();
        }
        else
            Response.Write(path + "/" + fileName);
}

Note: To use this code, one must use the System.IO namespace.

TATA NEN Hottest Startups Awards

Heyiiee everyone..

Our company got nominated for Tata NEN Hottest startups awards..

Start voting for us. Find below the voting process and help us to get what we deserve.

LeewayHertz Technologies | 2004

To VOTE please TYPE
HOT398 and sms to 56767
Akash Takyar | New Delhi | IT/ Internet/ Software
Nominated on Sep 26 2008 8:42AM | by
LeewayHertz Technologies - Snapshot
IPhone applications to market your business
Business Basics Show/Hide
Company Name LeewayHertz Technologies
Founded in 2004
Headquartered in New Delhi
Company website/URL www.leewayhertz.com
Industry IT/ Internet/ Software
Stage of the company Scaling up
Source of idea Systematic search for business opportunity
Awards & honors Will probably get the first one as TATA NEN Startup award.
Competition Show/Hide
Competitors IndiaNIC
How different if your product or service? It has... Identical or close substitutes available abroad
In what way is your product or service different? We provide complete solution from building an idea from scratch till the final product is ready for the market. We also use cutting edge technology to ensure our clients get effective applications developed in-house.
By The Numbers Show/Hide

2006 2007
No. of employees 0-5 6-15
No. of locations 0-1 0-1
No. of customers 2-5 6-15
Turnover Under 10 lacs 11-50 lacs
Profits 6 to 15 lacs 16-50 lacs
Primary source of initial funding Personal savings
Primary source of additional funding Family & friends
Raised institutional capital? No










Wednesday, September 24, 2008

iPhone Application Development – iPhone Accelerometer

Have you ever thought how the iphone displays the websites and the games you are playing on iPhone in portrait as well as landscape mode?

Here are points that would answer your query:-

1. A built in accelerometer responds to the major motions of the iPhone.

2. When you rotate your iPhone from Portrait mode to Landscape mode, the accelerometer detects the movement and changes the display accordingly.

3. So you can view a web page in portrait as well as landscape mode.

4. There are three elements that are used by accelerometer silicon mass, a set of silicon springs, and an electrical current.

5. The rotating iPhone causes the fluctuation which causes the electrical current to flow across the silicon spring.

6. The accelerometer registers these fluctuations and tell iPhone to adjust the display settings accordingly.



Google Phone debutes on 22nd October

Finally, google has come into mobiles. It's first phone was revealed today by T-Mobile USA, and it looks a lot like an iphone. Have a look:


T-Mobile USA showed off the G1, a phone that, like Apple Inc.'s iPhone, has a large touch screen. But it also packs a trackball, a slide-out keyboard and easy access to Google's e-mail and mapping programs.

T-Mobile said it will begin selling the G1 for $179 with a two-year contract. The device hits U.S. stores Oct. 22 and heads to Britain in November and other European countries early next year.

Android, the free software powering the G1, is a crucial building block in Google's efforts to make its search engine and other services as accessible on cell phones as they already are on personal computers. The company believes it eventually might make more money selling ads that get shown on mobile devices than on PCs, a channel that will generate about $20 billion in revenue this year.


Monday, September 22, 2008

New Web Site Development Worksheet

A new Web site is a big investment. To get the most out your site, therefore, it's helpful to establish what you want -- and need -- early in the planning stages. Whether your organization is in the process of creating a new Web site or revamping an existing one, these questions are a good place to start.

  • What is your organization's message? What do you want to communicate through your Web site?
  • If your organization already has a site, how will your new site improve what you already have? What can it bring you that your existing site doesn't?
  • If your organization doesn't already have a site, what will be the benefits of online exposure?
  • Who is your audience? Who would you like to reach?
  • How would your targeted audience use your organization's site? Why would they visit it? Why would they return to it?
  • How can your site best present your organization's point of view? What tone or voice is appropriate for your audience?
  • What will your site's main function be? Will it be a research or a development tool? A promotional space? A fundraising device? What will your site accomplish?
  • What types of content will your site include? How will this content be organized?
  • Are there other sites -- or features on other organization's sites -- that you want to emulate?
  • Should your site's look and feel be consistent with the other collateral your organization produces? How should it correspond, and how might it deviate?
  • What is your budget? (When calculating this budget, remember to factor in costs for both setup and maintenance.) You may need to do some research or get quotes to determine how much various features and services cost.
  • If your budget isn't enough to cover what you want, how might you get additional funding for your site? What additional resources can your organization allocate to Web development?
  • Can you create your new site in-house? How about maintain it? Who will provide for ongoing maintenance and updating?
  • If you aren't creating your new site in-house, who can you hire to do it? An individual consultant? A design firm? How will you go about sourcing these vendors?

Saturday, September 20, 2008

Asp.Net: Problem with the OnClientClick event of a Button Web Control

While working an ASP.NET 2.0 project today I ran across a problem with the OnClientClick event within the Button Web Control. The problem is that .NET renders this button:

<asp:Button ID="btnSave" runat="server" Text="Save & close" OnClientClick="Update ();" />
as

<input type="submit" name="btnSave" value="Save & close" onclick=" Update();" />


So when I click on the button, my JavaScript fires correctly but the page then submits – so to control this I added return false after my client-script ran, like so:

<input type="submit" name="btnSave" value="Save & close" onclick=" Update();return false;" />


This however, does not work; the page still submits. After looking at the rendered HTML I can see the problem right away -the button type is submit. What I need is for it to be a type of button.

An input control of type button, will not automatically submit the form. But how do I get .NET to render one?
The solution I found was in .NET there is an attribute (boolean) to the Button WebControl called UseSubmitBehavior. By setting it to false in the WebControl, like so:

<asp:Button ID="btnSave" runat="server" Text="Save & close" OnClientClick=" Update(); return false;" UseSubmitBehavior="false" />


Renders the input control like I want it to, as a button:

<input type="button" name="btnSave" value="Add" onclick=" Update(); return false;__doPostBack(‘btnSave’,'')" />


Notice that I still need to stop the execution of the JavaScript by returning false because .NET added __doPostBack(‘btnSave’,'') to the onclick event.

But the main difference is that by returning false the page DOES NOT submit. Now, I can go back to writing my client-script to manipulate the page and capture those changes when the real submit button is clicked and the server code takes over.