nikkiH 2 Junior Poster in Training

I assume someone needs to tell the teacher that. LOL
I was wondering why one wouldn't just regex for validation.

nikkiH 2 Junior Poster in Training

If you are not putting your code under C:\inetpub\wwwroot, then you need to tell IIS where to look for it. You appear to have put it in a normal directory. You can either make that a virtual directory in IIS, or move the whole thing under wwwroot.

I am a fan of virtual directories, personally.

nikkiH 2 Junior Poster in Training

Did you have a question (or three), or was this a job posting offer?

How you connect to a DB in VB highly depends on whether you're using VB6, VB.NET 1.1 or VB.NET 2.0 and what components you're using (web form, windows form, sqldatasource, sqlconnection, etc).

nikkiH 2 Junior Poster in Training

To help get you started:

import java.util.*;
 
public class Playing {
    
    public static void main(String[] args) {
        String ip = new String("127.0.0.1");
        StringTokenizer st = new StringTokenizer(ip, ".");
        while (st.hasMoreTokens())
        {
            // your code here
            System.out.println("token: " + st.nextToken());            
        }
        
    }
}
nikkiH 2 Junior Poster in Training

You can't just open/run an aspx page like that -- it has to go through IIS and the .NET engine.
Did you install .NET Framewrok and set up IIS on your machine?

nikkiH 2 Junior Poster in Training

You have a current application written in Classic ASP, and you want to add to it?
Where do you want the search button, and how do you want the results displayed?
If you already have an ASP app set up, you can use the same connection object and just make a recordset that runs your query.

I can give you example code from Northwind if you like, but I need to know how you want it displayed. ASP.NET has neat things like a datagrid, Classic ASP you have to do it all yourself.
If you have Dreamweaver, it can make Classic ASP coding a lot easier.

nikkiH 2 Junior Poster in Training

I'm not totally sure, but I think you need the new keyword?
This appears to be a functioning example of something similar in that it attaches a prototype function to the window scroll. Perhaps it will help.

http://javascript.internet.com/css/fixed-layer-manager.html

nikkiH 2 Junior Poster in Training
<asp:SqlDataSource ID="sda_nw1" runat="server" ConnectionString='<%$ ConnectionStrings:NORTHWIND %> ' 
        SelectCommand="SELECT orders.customerid, ContactName, count(OrderID) as numorders FROM orders join customers on orders.CustomerID=Customers.CustomerID group by orders.customerid, ContactName order by ContactName" 
        ProviderName="System.Data.SqlClient" OldValuesParameterFormatString="original_{0}">
        </asp:SqlDataSource>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sda_nw1" DataTextField="customerid"
            DataValueField="customerid">
        </asp:DropDownList><br />
nikkiH 2 Junior Poster in Training

What does your textbook say?
These are pretty classic exam questions...

nikkiH 2 Junior Poster in Training

What was the question?

nikkiH 2 Junior Poster in Training

TO_CHAR doesn't fail on null I don't think.

Try:
NVL(TO_CHAR(referred), 'NOT REFERRED')

nikkiH 2 Junior Poster in Training

MSDN has a nice article on the subject.
http://msdn2.microsoft.com/en-us/library/aa479015.aspx

nikkiH 2 Junior Poster in Training

The first thing I would do is set up a test page using only the datagrid. Get it data bound and working normally.
Once that is set, then I'd add the code for the user control, and see if even putting it on the page caused an error.

If it's still all good, then I'd pop the login page to hit the test page.
Is there an error now?

Baby steps and test pages are great troubleshooting tools.

If you need more help, you need to post real code and the real error, or I can only make guesses at what might be going on.

Your user control may not be saving state as you expect if you're getting an object expected error.

nikkiH 2 Junior Poster in Training

You include it exactly the same as you would in an html file. An aspx file is still markup, just like html, and normal markup tags are allowed in addition to special aspx tags.
So,
<script src="yourjsfile.js" type="text/javascript" />

nikkiH 2 Junior Poster in Training

The best way, in my opinion, is to use their API that they created just for such a task.
Here is a link to it and their instructions.
http://code.google.com/apis/ajaxsearch/?utm_source=en-ha-na-us-google-asa1a&utm_medium=ha&utm_campaign=en&utm_term=google%20search%20api

You have to sign up, but it's free.

nikkiH 2 Junior Poster in Training

Can you clarify?
You can set a form to target google search as easily as any other page using the action. This would be the same as the user going to google and typing in a search term.
If you want it to only search your site, you can do that, but it may only work on pages google indexed.
Google also has an API available for developers.

nikkiH 2 Junior Poster in Training

You can bind the grid whenever you like.
The method is DataBind()

nikkiH 2 Junior Poster in Training

You didn't post full enough code for me to test, so please clarify "doesn't work". Do you get an error? Did you check the javascript console (firefox) and/or turn on error messages (IE)?

nikkiH 2 Junior Poster in Training

Which event is this code running from?
Did you trace with Studio (debug)?

nikkiH 2 Junior Poster in Training

You take out the relevant javascript portions and save it as a .js file, then include it like any other javascript file in your aspx source.

nikkiH 2 Junior Poster in Training

Why don't you post what you have so far?
No one is going to code your whole assignment for you for free.

nikkiH 2 Junior Poster in Training

Are you perhaps looking for MultiView / GridView?

Standard components available in .NET are the same, regardless of your language of choice.

nikkiH 2 Junior Poster in Training

That's great, but since you're trying to teach us how NOT to use scriptlets, I'd love to know the right way to do this.

<%
response.sendRedirect("someUrl");
%>

Please share. :D
I'm much more a C# person than Java these days and the Java I did do was on an old crappy server that didn't fully support JSTL, so I have no idea how else you would do this. This is what Sun had on its site. Please tell me the better way to do this so I know for future reference.

peter_budo commented: Little respect wouldn't hurt +0
nikkiH 2 Junior Poster in Training

Using references is like adding things to classpath in java.
Many things are there by default.

The C# equivalent of import is "using".

i.e.
using System.Data;

Like Java classpath and import, both a reference and a using statement are generally required for C#.

nikkiH 2 Junior Poster in Training

Lots of ways, depending on what you're doing and what your goal is. It's called "paging".
http://www.google.com/search?sourceid=navclient-ff&ie=UTF-8&rls=GGGL,GGGL:2006-42,GGGL:en&q=asp+paging

If you use Dreamweaver, it has a paging component built in that isn't bad for IDE generated code.

nikkiH 2 Junior Poster in Training

Well, personally I'd start by asking my teacher for clarification if I was totally lost.
That's what they're there for.

Since I don't know what your teacher wants or expects, it's hard to help too much without a lot more details on the assignment.

nikkiH 2 Junior Poster in Training
nikkiH 2 Junior Poster in Training

Probably because you're setting PostBackURL in the same spot you're trying to use it.
PostBackURL is written out as client-side javascript on a button. If it is not set already at design time, you will see a need for 2 postbacks; one to set it and it gets written to the client, the next actually submits with the new PostBackURL.

nikkiH 2 Junior Poster in Training

Please share the non-scriplet way for us uneducated folks.

nikkiH 2 Junior Poster in Training

It's been awhile since I coded VB6, but isn't that the forecolor property in the IDE?

nikkiH 2 Junior Poster in Training
nikkiH 2 Junior Poster in Training

That's just a link, right?
Therefore, the linked page should work fine. If you just plug that link into your browser, does it work?

nikkiH 2 Junior Poster in Training

You don't have to display every column you select.
I use views with a bunch of columns as my datasource, and they work for several different grids.

nikkiH 2 Junior Poster in Training

Oh, and since it's a query, not a stored procedure, I don't use execute. I use open, which means I can get a record count if I want. You can't do that with execute.

Here's another example from some other code I have that might do either an exec or an open depending on other factors:

objRS.Open strSQL, objConn, adOpenStatic,adLockReadOnly, 1
...
' check for SQL errors
if Err.number <> 0 Then
   Response.Write "<h2>An Error Occurred</h2>"
...
end if
on error goto 0
...
if objRS.RecordCount <= 0 then
   recordcount = 0
   if Not ObjRs.EOF then
       while Not ObjRS.EOF
           recordcount = recordcount + 1
            ObjRS.MoveNext
       Wend
       ObjRS.MoveFirst
   end if
else
   recordcount = objRS.RecordCount
end if

debugOut "Record count is " & recordcount & "<br>"
nikkiH 2 Junior Poster in Training

Well, when I expect only one match, I test only for EOF, not BOF.

i.e.

Set rs = Server.CreateObject("ADODB.recordset")
rs.Open strSQL, objSpecs, adOpenStatic, adLockReadOnly, 1

if rs.EOF then 
   Response.Write "<p><b>Error</b>: No matches found in the database for record </p>"
else
   ...
end if
nekesa commented: Real persistance in troubleshooting. +1
nikkiH 2 Junior Poster in Training

Sure. A simple console app to demonstrate.

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            Console.WriteLine(fromDate.ToString("M/d/yyyy"));

            DateTime toDate = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 1);
            toDate = toDate.AddDays(-1);
            Console.WriteLine(toDate.ToString("M/d/yyyy"));

            fromDate = new DateTime(DateTime.Now.Year, 1, 1);
            Console.WriteLine(fromDate.ToString("d MMM yyyy"));
            toDate = new DateTime(DateTime.Now.AddYears(1).Year, 1, 1);
            toDate = toDate.AddDays(-1);
            Console.WriteLine(toDate.ToString("d MMM yyyy"));

        }
    }
}
nikkiH 2 Junior Poster in Training

Sure it's possible.
Where does the range come from? That is, the start and end dates of the current month and current year, or user input, or ...?

nikkiH 2 Junior Poster in Training

You make code to accept page number in the URL then use the links to pass the page number in the URL.

nikkiH 2 Junior Poster in Training

How do you want it?
Two date objects, a string, an array of dates ...?

nikkiH 2 Junior Poster in Training

Unless you're stuck with someone else's DAL, that is. ;)

You can write custom code to get the value, but it's a serious pain in the behind and isn't actually binding. You have to write custom code in the onItemDataBound event, I believe.

If you can write your own query, it's a LOT simpler.

nikkiH 2 Junior Poster in Training

IIS needs to be set up for .NET.
Is it?

nikkiH 2 Junior Poster in Training

PostBackURL is more equivalent to Server.Transfer than Response.Redirect.
It maintains ViewState and all the rest of the Page object and other State Bags.

Response.Redirect simply sends a 302 to the browser.

Also, PostBackURL simply sets a CLIENT-SIDE script event on a button. So it doesn't work in all situations. Server.Transfer stays on the server.

nikkiH 2 Junior Poster in Training

You have the close inside the read loop. Move it outside the loop.

nikkiH 2 Junior Poster in Training

This is pretty basic if I understand you.
Search shows a ton of tutorials and FAQs on the subject.
http://www.google.com/search?source=ig&hl=en&q=windows+forms+datagrid&btnG=Google+Search

nikkiH 2 Junior Poster in Training

Okay, no, that won't work like that.
Behind the scenes, all post back url does is change the onclick on the button CLIENT SIDE.
So changing it then trying to call onclick, before the code is written to the browser, won't work.
Here is view source from the browser.

onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, false, &quot;&quot;, &quot;http://www.daniweb.com/techtalkforums/post314320.html&quot;, false, false))" id="Button1" />

So, to solve your problem, you can still use transfer, or you can register client side script block to auto-call the button click event when the page loads.
Transfer is, in my opinion, the better option.

nikkiH 2 Junior Poster in Training

Ah, I see.
Hang on a few, let me trace it.

nikkiH 2 Junior Poster in Training

You don't have an On Error Resume Next in that code anywhere, do you?

nikkiH 2 Junior Poster in Training

Here's what I had.
Note that posting to the daniweb address actually causes an error due to them not accepting POST from outside their domain. However, this still indicates success at postbackurl.
Also, I choose an option before clicking that button.
This is .NET 2.0, which I assume is what you're using, because IIRC 1.1 doesn't support this sort of thing.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5"  %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<hr />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="http://www.daniweb.com/techtalkforums/post314320.html">Daniweb</asp:ListItem>
<asp:ListItem Value="~/test.aspx">Uke</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Set the destination.
        Button1.PostBackUrl = RadioButtonList1.SelectedValue;

        //This should send me to a different page right?
        Button1_Click((object)Button1, e);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    }
}
nikkiH 2 Junior Poster in Training

row = GridView.SelectedRow;

SelectedRow?
Where are you trying to put that? Unless you make someone first select a row before being able to edit it, it isn't the right thing to use.

In general, GridView is very much out of the box as far as editing and whatnot.

Here's a small example using Northwind.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default2.aspx.cs" Inherits="_Default2"   %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>

</head>
<body>
<form runat="server" id="Form1">
    <div>
        <asp:SqlDataSource ID="sda_customers" runat="server" ConnectionString='<%$ ConnectionStrings:NORTHWIND %> ' 
        SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax] FROM [Northwind].[dbo].[Customers]" 
        UpdateCommand="UPDATE [Northwind].[dbo].[Customers] SET [CompanyName]=@CompanyName, [ContactName]=@ContactName, [ContactTitle]=@ContactTitle, [Address]=@Address,[City]=@City, [Region]=@Region,[PostalCode]=@PostalCode,[Country]=@Country, [Phone]=@Phone, [Fax]=@Fax WHERE [CustomerID]=@CustomerID"
        ProviderName="System.Data.SqlClient"
        >
        </asp:SqlDataSource>
        
        <asp:Label ID="Label1" runat="server"></asp:Label><br />
        <br />
        Filter:
        <asp:TextBox ID="txtFilterExpression" runat="server"></asp:TextBox>
        &nbsp;
        <asp:Button ID="btnFilter" runat="server" OnClick="btnFilter_Click" Text="Button" /><br />
        &nbsp;
        <asp:GridView ID="gvCustomers" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="true"
            DataSourceID="sda_customers" DataKeyNames="CustomerID" OnRowCommand="gvCustomers_RowCommand" OnRowUpdated="gvCustomers_RowUpdated"  AutoGenerateEditButton="True" OnRowUpdating="gvCustomers_RowUpdating">
        </asp:GridView>
        </div>

    </form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default2 : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            sda_customers.FilterExpression = txtFilterExpression.Text;
            if (ViewState["updating"] == null ||
                ViewState["updating"].ToString() == "false")
                gvCustomers.DataBind();

            string key = (string)ViewState["editing"];
            int selectedindex = 0;
            bool found = false;
            if (key != null)
            {
                foreach (DataKey dataKey in gvCustomers.DataKeys)
                {
                    if (dataKey.Value.ToString() == key)
                    {
                        gvCustomers.EditIndex = selectedindex;
                        found = true;
                        break;
                    }
                    else selectedindex += 1; …
nikkiH 2 Junior Poster in Training

Yes, and for me, it does.
You're inheriting code. Did you mean to do that?

Inherits="PassParameters._Default" %>

You had a couple other errors in there I fixed without thinking about it, too.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5"  %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<hr />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="http://www.daniweb.com/techtalkforums/post314320.html">Daniweb</asp:ListItem>
<asp:ListItem Value="~/test.aspx">Uke</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>