Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Thursday, March 29, 2012

Please explain me following lines

Hi All,

Please explain me following two lines:

if (combined.Length != 0)

prefix += appendAnd ? " and " : " ";

In above line what is the use of '?' and ':'

Thanks and regards,

Swapnil.

That is aTernary Expression.

If means,

If the var appendAnd evaluates to True

then perform the operation (+=) with the data directly after the question mark

else

perform the oprtation with the data after the colon :

Please explain what "Empty path has no directory" means with Server.MapPath

Hello,

I have the following line of code in a script...

litMsg.Text = Server.MapPath("/");

where litMsg is an ASP.Net Literal control. When I try and run this
page, I get the error ...

System.ArgumentException: Empty path has no directory.

Anyone any idea what this means? I have used Server.MapPath many times
before without error, I'm not sure why it suddenly stopped working here.

I'm sure I'm missing something blindingly obvious and would be grateful
if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)IN case it's of any use to anyone, I found out that the problem was
caused by me having the following two lines in Page_Load...

HttpContext myContext = HttpContext.Current;
myContext.RewritePath("/");

I'm not actually sure *why* I had those lines there, they must have been
from something I was doing before. As soon as I removed them, the
Server.MapPath worked fine.

If anyone has an explanation, I would like to hear it ;-)

>Hello,
>I have the following line of code in a script...
>litMsg.Text = Server.MapPath("/");
>where litMsg is an ASP.Net Literal control. When I try and run this
>page, I get the error ...
>System.ArgumentException: Empty path has no directory.
>Anyone any idea what this means? I have used Server.MapPath many times
>before without error, I'm not sure why it suddenly stopped working here.
>I'm sure I'm missing something blindingly obvious and would be grateful
>if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)

Monday, March 26, 2012

Please Help - HW question

Go here:
http://sb.pch.com/cat/05/01-55/mult...hmail.com&ti=mr.

There is one line of code that needs to be changed in order to accommodate a
new feature. In order to allow us to accept the character "$" in the
address1 field, what is the single line of code that would have to be
updated to correctly validate the address1 field when the submit button is
clicked. Hint: this information is 100% within your attainable view based on
the information provided.Why shall I go there?

Eliyahu

"giganews" <rob012669@.inbox.com> wrote in message
news:jYKdnRje3IuM0VbfRVn-3w@.rcn.net...
> Go here:
http://sb.pch.com/cat/05/01-55/mult...hmail.com&ti=mr.
> There is one line of code that needs to be changed in order to accommodate
a
> new feature. In order to allow us to accept the character "$" in the
> address1 field, what is the single line of code that would have to be
> updated to correctly validate the address1 field when the submit button is
> clicked. Hint: this information is 100% within your attainable view based
on
> the information provided.

Friday, March 16, 2012

Please Help me understand how this works......

Hi. I have this code below and wondering what file I need to import to get the pageContentsCell.Controls.Add(control) line to work.

Private Sub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.Load,Me.Load' Save DepartmentID from the query string to a variableDim departmentIdAs String = Request.QueryString("departmentID")' Save the search string from the query string to a variableDim searchStringAs String = Request.QueryString("Search")' We need to find out if the ViewCart parameter has been suppliedDim viewCartAs String = Request.QueryString("ViewCart")' Load page contentsIf Not viewCartIs Nothing Then' we display the shopping cartDim controlAs Control control = Page.LoadControl("UserControls/ShoppingCart.ascx") pageContentsCell.Controls.Add(control)ElseIf Not searchStringIs Nothing Then' you're searching the catalogDim controlAs Controlcontrol = Page.LoadControl("UserControls/SearchResults.ascx") pageContentsCell.Controls.Add(control)ElseIf Not departmentIdIs Nothing Then' you're visiting a department or categoryDim controlAs Controlcontrol = Page.LoadControl("UserControls/Catalog.ascx") pageContentsCell.Controls.Add(control)Else' you're on the main pageDim controlAs Controlcontrol = Page.LoadControl("UserControls/FirstPage.ascx") pageContentsCell.Controls.Add(control)End If End Sub Private Sub viewCartButton_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles viewCartButton.Click' Get the query string as a NameValueCollection objectIf Request.QueryString("ViewCart")Is Nothing Then Response.Redirect("default.aspx?ViewCart=1&" & _ Request.QueryString.ToString())End If End Sub
What's the error message you got for the linepageContentsCell.Controls.Add(control)? You may take a look atCreating Custom Web Controls with ASP.NET 2.0

Please help me with this simple line of code.

Hello,
i am creating an ASP.net / VB web site with Dreamweaver MX 2004.
I have a form and a "Insert Record Behavior" to insert the form values in
the database.
Dreamweaver puts this code in the end of the form:
..
<input type="hidden" name="MM_insert" value="myForm"> (1)
</form>
The form is in a Multipanel. So when i first click the "Next" button the
form values are inserted in the database.
I want the form values to be inserted in the database only when the "Finish"
button is pressed.
I have the code which detects when the "Finish" button is pressed. All i
need is to know how to give the order not in (1) but inside the following
code:
Sub btnFinish_Click( s As Object, e As EventArgs )
End Sub
I am on this since today morning but until know i have no idea of how to do
this. Please help me. I tryied and looked for every options.
Thank You,
MiguelI believe what you are asking is "how do I code for inserting a record when
the finish button is clicked"...is that about right?
If this is what you are asking, you have not provided enough information, su
ch as what is the source file you are wanting to update.
You will need a Connection Object, which typically come in 3 flavors (ODBC,
OLEDB, or SQL)
You will need a connection string to properly build your command object. Th
ere are places on the web which provided examples of connection strings to t
he 3 flavors noted above. Seach on ConnectionString or OLEDB Connections
You will need a command Object, again, these come in the same 3 flavors.
To properly build the Command ogject, you will need to Connection Object dis
cussed above and your query - Something line "Insert into MyDatabaseName Val
ues( MyValue1,...MyLastValue) .
Once you have all of that in-place, you will then need to open the connectio
n.
Then you will use the "ExecuteNonQuery" method of the command object, which
will invoke your query.
If you have never created a connection to your database/file or every writte
n a query, you have a lot of studying to do.

Please help me with this simple line of code.

Hello,

i am creating an ASP.net / VB web site with Dreamweaver MX 2004.

I have a form and a "Insert Record Behavior" to insert the form values in
the database.

Dreamweaver puts this code in the end of the form:
...
<input type="hidden" name="MM_insert" value="myForm"> (1)
</form
The form is in a Multipanel. So when i first click the "Next" button the
form values are inserted in the database.
I want the form values to be inserted in the database only when the "Finish"
button is pressed.

I have the code which detects when the "Finish" button is pressed. All i
need is to know how to give the order not in (1) but inside the following
code:

Sub btnFinish_Click( s As Object, e As EventArgs )
>> I want to give the order here.
End Sub

I am on this since today morning but until know i have no idea of how to do
this. Please help me. I tryied and looked for every options.

Thank You,
MiguelI believe what you are asking is "how do I code for inserting a record when the finish button is clicked"...is that about right?
If this is what you are asking, you have not provided enough information, such as what is the source file you are wanting to update.

You will need a Connection Object, which typically come in 3 flavors (ODBC, OLEDB, or SQL)
You will need a connection string to properly build your command object. There are places on the web which provided examples of connection strings to the 3 flavors noted above. Seach on ConnectionString or OLEDB Connections
You will need a command Object, again, these come in the same 3 flavors.
To properly build the Command ogject, you will need to Connection Object discussed above and your query - Something line "Insert into MyDatabaseName Values( MyValue1,...MyLastValue) .
Once you have all of that in-place, you will then need to open the connection.
Then you will use the "ExecuteNonQuery" method of the command object, which will invoke your query.

If you have never created a connection to your database/file or every written a query, you have a lot of studying to do.