.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Invalid expression term 'else'

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

Can you please tell me what I am missing???

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZipCodes
    class Program
        static void Main(string[] args)
            int zip;
            double price;
            string inputzip;
            double miles;
            string inputmileage;
            double deliverycost;
            double costpermile;
            bool isValidzip = false;
            int[] zips = { 77001, 77002, 77003, 77004, 77005};
            double [] prices = {1.25, 1.50, 1.55, 2.00, 2.25, 1.50};

View Complete Post

More Related Resource Links

invalid expression term "public"


I've been reading beginning asp.net 3.5 and following basic tutorials from this site and learnvisualstudio.net.


I don't think I've came across why you cannot create public variables inside page_load. I always have to declare public variables before the page_load block for them to work. The reason why I would like to use public variables inside other blocks is because I like data binding expressions into my .aspx page and it will only let me <%# varibleName %> expressions that are public. I'm sure there are better methods like creating Labels and setting text property equal to my private strings name but I end up with the <spans> that labels generate and Im a control freak, I like putting single type data expressions inside <p> or <h3> which makes it easier for me to manage my CSS file for the appearances of them. I guess the queston I would like answered mostly is why can't I declare public variables inside page_load. 

Invalid length for a Base-64 char array for my coding in ASP.net C#. How to solve it ?


Hi Friends ,

I have done encrypted password and decode but i got error  like  this  " Invalid length for a Base-64 char array" .

Pls help . Thanks


psswd = txtPassword.Text;

pwed = base64Decode(psswd);

public string base64Decode(string sData)
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(sData);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            string result = new String(decoded_char); return result;

[How??] Lamda expression with ByRef parameter


How to write lamda expression with ByRef/ref parameter in c# ??

The code below causing syntax error:

item.OnAction = (p1, p2, ref p3) => {
   return true;

item.OnAction = (p1, p2, & p3) => {
   return true;

Express Yourself: Encoding Videos Using Microsoft Expression Encoder 3 SDK


Video on the Web involves huge amounts of data. Learn the best way to manage and move that data with the help of Microsoft Expression Encoder 3.

Adam Miller

MSDN Magazine June 2010

Security Briefs: Regular Expression Denial of Service Attacks and Defenses


Microsoft security expert Bryan Sullivan believes denial-of-service blackmail attacks will become more common as privilege escalation attacks become more difficult to execute. He demonstrates how to protect your apps against regular expression DoS threats.

Bryan Sullivan

MSDN Magazine May 2010

Silverlight: Create Animations with XAML and Expression Blend


In this excerpt from his upcoming book, Laurence Moroney explains the basics of Silverlight animation and the animation tools available in Expression Blend.

Lawrence Moroney

MSDN Magazine August 2008

Silverlight: Create a Custom Expression Encoder Publishing Plug-In


Laurence Moroney demonstrates how to employ the Expression Encoder plug-in APIs by building and debugging a simple FTP upload plug-in.

Laurence Moroney

MSDN Magazine February 2008

Hanselminutes Podcast 227 - Inside Expression SuperPreview with developer Mike Calvo

Scott talks to Mike Calvo, a Microsoft Lead Developer based out of Minnesota (!) about Expression SuperPreview. SuperPreview helps developers and designers with cross-browser CSS and HTML issues. How'd they build it and with what? What's inside? How does the cloud fit in and how do they support Safari? I played with SuperPreview a bit last year, but started looking at it again last month when I noticed that version 4 has introduced support for Safari on Mac via a Cloud-based Remote Service. I fired up Expression SuperPreview 4, and saw this: Then I signed up: Which enabled Mac Safari for this initial beta. I assume they'll add a pile of other browsers. If I don't see immediate browser support for ALynx, the Amiga port of Unix...(read more)

Help with regular expression


I am using this regular expression: /.*-lyrics-.*$

and I need the expression find urls like this:

and it do really does that!

The problem is that it finds also this URL:

Whar regular expression should I use to exclude urls that end with /lyrics ?

Thanks :]



Regular Expression to Match


Here is the kind of text I want to match via a regular Expression

The id="dgSchedule" is always present in the TAG but its location may differ

The table is span over multiple line/contains white spaces/tabs...

I have the regular expression to match the start and end tag respectively over a single line

\<table .*\>


The problem is to match the whole table span over multiple lines

<table cellspacing="0" rules="all" border="1" id="dgSchedule" style="border-style:None;height:100%;width:100%;border-collapse:collapse;">
	<tr class="blackbar" align="center" style="background-color:#7FB4DE;font-family:Verdana;font-weight:bold;height:20px;">
		<td>From Place</td><td>To Place</td><td>Time</td><td>Bus Type</td>

	</tr><tr style="background-color:#DEECF5;">
	</tr><tr style="background-color:#EFF5FA;">
	</tr><tr style="background-color:#DEECF5;">


asp expression bound to user control parameter?


How can I get pass the DataKey of a GridView to a usercontol, preferably without code behind.

Why doesn't this work:

<ucOrderDetails:AJAX_OrderDetail ID="od1" runat="server" OrderNumber='<%# GridView1.SelectedValue.ToString() %>'  />

GridView1 is just a list of orders with a DataKey of OrderNumber.

od1 is not inside of a databout control, does it need to be?

Syntax error (missing operator) in query expression

Good Day Gurus!

I have a Excel user application which has a user form (named 'Registo') that displays criteria and an image that has been entered in it's corresponding spreadsheet. This works the way it should.  There's also the ability to search the spreadsheet via a form (by clicking 'Pesquisar' button) this opens a search form. However, I having a bit of a problem with it. When I try to search for something it basically doesn't do anything at all. It just sits there. So I tried to debug it and I think I'm having a problem with either the JET db engine or somethign with teh query or maybe I don't have the correct reference.

I 'borrowed' this Excel application from another forum because it's exactly what I'm looking for! However, I suck at vb.

So I was hoping somebody could take a look at the code and see if I'm missing something?  I'm kinda' desparate to get this working because I'm been trying to figure it out for days and I'm running out of time.  Cry
Option Explicit

'constantes para auxiliar na verificação do código
Private Const Ascendente As Byte = 0

Linq2Sql error: "Invalid attempt to call Read when reader is closed."


I've read up on this error from other posts and on other sites, but haven't found a solid resolution to the issue yet. My setup is as follows:

I have a RepositoryBase class that fields certain db calls that all repositories need to perform. In one such call, "GetSecurityGroup", it works most of the time, but will seemingly at random throw an exception with the error "Invalid attempt to call Read when reader is closed." All other Repository classes inherit from this one, and they all use the same DataContext object, which I understand isn't thread safe. Since there could be multiple calls to the DataContext object on the same page, perhaps one is using the DataContext when the next tries to do so. I'm not sure. What can I do to ensure this doesn't happen?

How to CATCH "Invalid postback or callback argument" exception?



How can I catch this exception? I do not want it to stop my page execution. Can/Should I do that?

Server Error in '/' Application.
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally

WebResource.axd - Padding is invalid and cannot be removed error



I'm working on a site that is hosted externally, and the admin just sent me an email syaing they're getting this following error:


Event code: 3005 

Event message: An unhandled exception has occurred.

Event time: 11/17/2008 8:11:24 AM

Event time (UTC): 11/17/2008 8:11:24 AM

Event ID: 5d3b54c09a24463ca8fb03f22692e0bb

Event sequence: 731

Event occurrence: 3

Event detail code: 0

Application information:

Application domain: /LM/W3SVC/1776482879/ROOT-1-128713348984007217

Trust level: Full

Application Virtual Path: /

Application Path: D:\....

Machine name: ****

Process information:

Process ID: 2272

Process name: w3wp.exe

Account name: ****

Exception information:

Exception type: CryptographicException

Exception message: Padding is invalid and cannot be removed.

Request information:

Request URL: http://sitename/WebResource.axd?d=_O9D297IUE-qcgMP0yFe-w2&t=633468747532779057

Request path: /WebResource.axd

User host address:


Is authenticated: False

Authentication Type:

Thread ac

Invalid URL"" after copy or move a document.



We have an website that have 3 libraries. The "first Library" is used only to edit documents and it's called "my documents". When a user finish of edit your documents here, they start a workflow that will check fields in the document and move the document for the second library (using Sharepoint Designer Workflow - without custom actions).
In "second library" we have a big workflow. This WF has some steps for approve, collect feedback, generate sub-tasks and others things related for the document. This WF use many custom actions in (Sharepoint Designer).
When this WF arrives to the end, the document is moved to "third library", that is a official repository of documents in the enterprise.
The entire cycle works fine. But when someone creates a internal copy of the document in the "first library" to begin again the flow, we receive a Invalid Url error. It occurs when any update operations is executed over the document item, the value is conserved but the error is displayed. After it, we can not execute other workflows over the item.
If we save the document in local disk, delete the library item, and then upload it again, the problem is solved.

Some one have an idea about why and how solve it?  We are using WSS 3.0.

The following is an error registred in log file when you d

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend