codehutch.com

Online Code Repository

To assign a role to a new user, we usually use the following code. We call this on the CreatedUser event of the ASP.NET CreateUserWizard Control:

protected void CreatedUser(object sender, EventArgs e) {
Roles.AddUserToRole(cuwRegister.UserName, “Registered User”);
}

The code worked fine for me but not when I customized the CreateUserWizard Control where I encountered this error:

The parameter ‘username’ must not be empty.
Parameter name: username

For some reason, the cuwRegister.UserName gives an empty string thus the error. So I used the FindControl method to access the UserName textbox:

TextBox userName = (TextBox)cuwRegister.CreateUserStep.ContentTemplateContainer.FindControl(”UserName”);
Roles.AddUserToRole(userName.Text, “Registered User”);

To learn how to customize the CreateUserWizard Control, go to MSDN.

Some tasks are just too complicated for dynamic query building and/or require a greater level of control. To handle this, SubSonic supports stored procedures. Each stored procedure will produce an equivalent static method in the class defined in the configuration file. By default this is SPs. Each method will have one parameter for each stored procedure parameter and return a StoredProcedure object.

SubSonic.StoredProcedure sp = SPs.CustOrderHist(customerID);

If you have created new stored procedures, read my post on how to:
Add New Stored Procedures to dashCommerce

Now that SubSonic recognizes your custom stored procedures, the next question is how to access/get their return value?

Read the rest of this entry »

All stored procedures included in the configuration file (Store/App.config) have an equivalent static method in: Store/Models/Generated/StoredProcedures.cs

When I was new to dashCommerce I didn’t figure this out right away.

If you created new stored procedures, you need to update this SubSonic-generated StoredProcedure class to include your new stored procedures. To do so, modify the configuration file, look for the “includeProcedureList” attribute. Add the names of your new stored procedures in the list. Notice this line:

stripSPText=”dashCommerce_Store_”

Read the rest of this entry »

I have a web user control (.ascx) that holds my product DataList. This product DataList has an ‘add to cart’ button in each item. When I hit one of the ‘add to cart’ button, the ‘Invalid postback or callback argument’ error shows up. Postback from other controls are fine.

<asp:DataList ID=”dlCatalog” runat=”server” SkinId=”catalogList”>
<ItemTemplate>
<div class=”productBox”>
<div class=”productImageContainer”>
<asp:HyperLink ID=”hlImageLink” runat=”server” NavigateUrl=’<%# GetNavigateUrl(Eval(”ProductId”).ToString(), Eval(”Name”).ToString()) %>’ SkinID=”noDefaultImage” />
</div>
<asp:HyperLink ID=”hlProduct” runat=”server” NavigateUrl=’<%# GetNavigateUrl(Eval(”ProductId”).ToString(), Eval(”Name”).ToString()) %>’ Text=’<%# Eval(”Name”) %>’ CssClass=”catalogProductName” />
<br />
<asp:Label ID=”lblRetailPrice” runat=”server” CssClass=”retailPrice” />
<asp:Label ID=”lblOurPrice” runat=”server” CssClass=”ourPrice” />
<br />
<asp:LinkButton ID=”lbAddToCart” runat=”server” OnCommand=”lbAddToCart_Click” CommandArgument=’<%# Eval(”ProductId”).ToString() + “;” + Eval(”Name”).ToString() %>’ CssClass=”button” Text=”Add To Cart” />
</div>
</ItemTemplate>
</asp:DataList>

The following is the complete error message: Read the rest of this entry »

Tweet Via SMS FOR FREE!

A sweet treat for Philippine resident Twitter addicts, an online application that allows users to tweet via SMS FOR FREE! The application is called, ISIP or “I Speak over Internet Protocol”.

ISIP enables Filipino subscribers of Twitter to post updates to their Twitter accounts via SMS FOR FREE! Get an account now! - isip.ph

Twitpocalypse Is Coming

That’s right, the Twitpocalypse is almost here.

Before you rush out for canned food and medical supplies, let’s take a closer look at the Twitpocalypse.

The Twitpocalypse is predicted to be this monstrous event that will ravage Twitter and leave all Twitterers without a place for their 140 characters of text… and we are mere days from it happening.

Are you nervous about the Twitpocalypse? Tell us.

The Twitpocalypse will happen on June 14, 2009 @ 7:10:53 GMT (at the time of this writing).

The Twitpocalypse is nearly upon us!

Below is an explanation of how and why the Twitpocalypse will go down…

The Twitpocalypse is similar to the Y2K bug. Very soon the unique identifier associated to each tweet will exceed 2,147,483,647

“For some of your favorite third-party Twitter services not designed to handle such a case, the sequence will suddenly turn into negative numbers. At this point, they are very likely to malfunction or crash.”

I’ll see if I can explain this a little further for you. Each Tweet has a unique number assigned to it, for identification purposes… and those numbers are about to cross the threshold where they can be given a 32-bit integer, which only go from -2,147,483,648 to 2,147,483,648. So this means that about two billion Tweets have been sent!

What’s ironic about this whole thing is people are Twittering about the Twitpocalypse, and by doing so, they’re adding to the problem that is the core of the Twitpocalypse. Talk about irony.

Tweet contributing to the Twitpocalypse

Recently, I talked with the lead developer of Twellow, Matthew Daines, and asked him about the Twitpocalypse…

“I haven’t researched it too much, but I doubt this will be a major issue. Sure, some apps might have some funny hiccups, faulty tweet references, or other problems, but any app that’s being used will address the issue, and it will be forgotten, in my opinion“.

See folks, the Twitpocalypse is something to keep an eye on… but nothing to induce a panic. Oh, and don’t you think if something was wrong with Twitter they would’ve mentioned something about it by now?

Look at Y2K, a much bigger deal, and it turned out to be a non-event… but just in case, anyone know if you can get Wi-Fi in a bomb shelter?

By Jeremy Muncy
Source: WebProNews
Check out twitpocalypse status.

I encountered this error while running an old project, based from ASP.NET 1.1 Commerce Starter Kit and dashCommerce, previously called ASP.NET 2.0 Paypal eCommerce Starter Kit. It was recommended in dashCommerce installation to create a separate application pool solely for the dashCommerce project’s virtual directory. All was running smoothly until I installed it more than a couple times and missed this step along the way and thus it gave me “Server Application Unavailable” error.

This error might also mean something else, I’m only referring to the following.

The Problem:
Running at least two applications in different ASP.NET Frameworks (1.1 and 2.0/3.0) side by side could mean that somewhere you are trying to run 1.1 applications and 2.0/3.0 applications within the same process.

The Solution:
Create different application pools in IIS for each ASP.NET Framework, one for 1.1 applications and the other for 2.0 applications.

Solution Source: ASP.Net Forums

Image Opacity Using CSS

Here is an illustration on how to use CSS to modify the opacity of ‘image-links’ and create a nice effect

CSS:

img{
border:none;
}

updated version

.link img{
-ms-filter: “alpha(opacity=50)”; /*IE 8*/
filter: alpha(opacity=50); /*lower IE versions*/
opacity: 0.5; /*FF*/
}

.link:hover img{
-ms-filter: “alpha(opacity=100)”; /*IE 8*/
filter: alpha(opacity=100); /*lower IE versions*/
opacity: 1; /*FF*/
}

deprecated

.link img{
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);
-moz-opacity: 0.5;
}

.link:hover img{
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
-moz-opacity: 1;
}

How to use:

<a href=”#” class=”link” ><img src=”superman.jpg”/></a>

Sample:

Thanks for the input j.j.  :)

I was trying to deploy my Project using Visual Studio 2008 a while ago, when I encountered this Error:

“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.”

And I had no idea why it was happening. I was not even trying to access my project in a browser (I was just trying to deploy!). I wasted almost an hour trying to figure it out before I luckily stumbled to Rob Gruen’s blog. Though his case was different (I did not upgrade), I hurriedly followed his suggestion. I search for web.config file in my project’s folder and to my surprise, there were two of them. Suddenly, I remember that I was testing something and added a test-website inside my project which contains a web.config file. I just deleted the whole test-website and, boom! the deployment went smoothly. So, if you encounter this error, just remember that you cannot use multiple web.config in one application.

Export DataTable To Excel (VB .NET)

I was digging through my files when I found this subroutine and I thought, maybe somebody out there might need it. It’s not my original code though (and I forgot where I got it). Anyhow, I just wanted to share it and here it is:

Public Sub ExportToExcel()

Dim table as Datatable = “Query your datatable here”
Dim name as String  = “filename”

Dim context As HttpContext = HttpContext.Current
context.Response.Clear()
For Each column As DataColumn In table.Columns
context.Response.Write(column.ColumnName & “,”)
Next
context.Response.Write(Environment.NewLine)
For Each row As DataRow In table.Rows
For i As Integer = 0 To table.Columns.Count - 1
context.Response.Write(row(i).ToString().Replace(”,”, String.Empty) & “,”)
Next
context.Response.Write(Environment.NewLine)
Next
context.Response.ContentType = “text/csv”
context.Response.AppendHeader(”Content-Disposition”, “attachment; filename=” & name & “.csv”)
context.Response.[End]()

LoadData_Base()
End Sub

« Previous Entries  

Calendar

March 2010
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Locations of visitors to this page

Page Rank