|
hi ,
can any one help me out writting code for Advanced search in ASP.NET
because i am a fresher .
CDHU
|
|
|
|
|
maybe this is useful
http://www.codeproject.com/aspnet/DotLuceneSearch.asp
MHF
|
|
|
|
|
plz make this difference clear for me
what is the difference between oninit and onload.
i want to make the object only once, but these methods will be called again on button click.
where should i call the object
either in oninit
or in onload
|
|
|
|
|
They are just two events that occur in the beginning of the life cycle of a control.
When you click a button, it will cause a postback. A postback is a request to the server to create a page. When the page is created, all controls in it is created. If you don't create your control in every postback, it would be missing from the page when it loads in the browser.
---
b { font-weight: normal; }
|
|
|
|
|
just put your code into !Page.IsPostBack block....
<< >>
|
|
|
|
|
protected void btnDisplayPopUp_Click(object sender, EventArgs e)
{
Page.RegisterStartupScript("MyPopUpScript", @"window.open('http://server_name/app_name/pop_up_window_page.html');");
}
in aspx page:
<aspx:button runat="server" id="btnDisplayPopUp" onclick="btnDisplayPopUp_Click" text"open="" pop="" up="" window"="">
THANKS buddy, some one has told me this solution for pop-up window.
but
it opens a new page not a pop-up window
means....
not a page like having no menu-bar and no tool-bar.
i just want to have a window like alert on bottom-right corner by e-buudy.com that "you have signed in"
thanks a lot..
|
|
|
|
|
hi Mairy,
Try this.
Dim strScript As String = "" & _
"window.open('webform1.aspx',''," & _
"'height=200;width=200px;left=150;top=100;menubar=no;resizable=yes;scrollbars=no;status=no;titlebar=no;toolbar=no');" & _
""
Response.Write(strScript)
Thomas
|
|
|
|
|
I'll just answer your next question after following Thomas' advice: "Yes, that shows a popup window, but the layout of my page gets all distorted".
That is because you are writing out the script before the doctype tag. That will make the browser ignore the doctype tag, so the page is rendered in Quirks Mode.
Use RegisterStartupScript to add the script to the page.
Also: The second parameter is the name of the window. Use a proper name, or use '_blank' if you want to open a new window.
---
b { font-weight: normal; }
|
|
|
|
|
I have the following html control on asp.net page (2.0):
<input id="ButtonPing" style="width: 91px" type="button" value="Ping" onclick="CallServer2()"/>
and also have the following javascript defined:
<head runat="server">
<title>Get Map</title>
<script language="javascript" type="text/javascript">
function CallServer2()
{
var arg = document.all['DropDownListTrailer'].value;
var context = new Object();
document.getElementById('DivStatus').innerText = "Please Wait ...";
CallServer(arg, context) // AJAX
}
function ReceiveServerData(arg, context)
{
document.getElementById('DivStatus').innerText = arg;
}
</script>
</head>
The above code will only work on Internet Explorer and does not work on Mozilla.
Under Mozilla, when I click the button, the click event is never finished.
Does anyone have the same problem ? I have been fighting this for the last week.
Rookie Programmer
|
|
|
|
|
That is because you are using IE-specific code.
The document.all collection is not part of the standard, and only exists in IE.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you for your help
I comment out all lines except one, but still have the same problem.
function CallServer2()
{
var arg = "xyz" //document.getElementById('DropDownListTrailer').value;
// var context = new Object();
document.getElementById('DivStatus').innerText = "Please Wait ...";
// CallServer(arg, context)
}
Rookie Programmer
|
|
|
|
|
Have you opened the Javascript Console, so that you see any error messages that might come?
---
b { font-weight: normal; }
|
|
|
|
|
This could probably also be in the SQL forum but nevermind.
What i am trying to do is create a generic class for storing my query results. At the moment i have a Database class that i can call an queryDatabase(string queryString) method that i call with SELECT statements. This returns a dataset populated with the query results.
Then in each of my classes such as Player, Item etc (making a web game here) i would do something such as:
Database db = new Database();
DataSet playerResultSet = db.queryDatabase("SELECT name FROM Player WHERE id = " + id);
if (playerResultSet.Tables.Count > 0)
{
DataTable playerTable = playerResultSet.Tables[0];
if (playerTable.Rows.Count > 0)
name = (string)playerTable.Rows[0]["name"];
}
This would give me the name of the playerID that i searched for.
What i am looking to do is to remove the code that i pasted to a separate, generic, class so that my classes such as Player and Item don't have to use DataSets, DataTables etc. I'm wondering if this is possible really since it will have to be generic, which creates problems since i wont know which table has been searched or the rows/columns in it and also the number of results.
So ideally this generic class would have methods to get the number and names of tables/rows or whatever and the values in them.
Has anyone ever had this problem / created a similar class / knows what i'm talking about?
Thanks for the help.
Tony.
|
|
|
|
|
toptone78 wrote: Has anyone ever had this problem / created a similar class / knows what i'm talking about?
I doubt anyone here does. And they will reply with something about ado.net too!
So anyways you can create a player class and enclose it inside generic list
List<PlayerClass>
public class PlayerSort : ICompare
then when sort just pass in a new instance of that class
also populating classes;
lets say you have this
select PlayerName from Players
you create a class like this
public class Players
{
public string PlayerName{ get; set; ... }
}
then using reflection you can store the name you get from a reader
PropertyInfo prop = this.GetType().GetProperty(string name from the read for the column );
prop.SetValue();
this will load your entire object
you can do the same for Updating and Loading with reflection.
So while people are writing all types of code, you only need 4 lines of code to handle all database calls
And ADO.NET sucks by the way. Its bulky, huge, slow, and a waste of resources. <-- I'm sure that will start a good forumn Besides ADO.NET is just a do all IListSource.
And by the way, in c# 3.0 it does this anyways. With the new QLink and XLink. Unless the programmer is from a Java background they dont think this way
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Well my Database class does not use ADO.NET it uses SqlConnection, SqlCommand and SqlDataAdapter which fills a DataSet.
I'm not sure i really understood your reply, sorry.
|
|
|
|
|
well all of the above is ado.net.
and its faster to use a data reader. it uses a fire hose cursor
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Alright fairy muff. But is it possible to build a generic class like i suggested?
|
|
|
|
|
yeah just build a base class and have all inherit from that
public class GenericClass{}
public class PlayerClass : GenericClass{}
Remember tho classes should have a 1:1 relationship with the database
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
and by the way. What I was talking about is loading a database record into a class from a generic base class.
So you'd create
public class GenericClass
{
public virtual void Load();
public virtual void Update();
}
Inside update you would test to see if the class has an id. If it does then this is not a new class otherwise it is.
I usually make my stored procs do update and inserts inside the same proc for less code to keep up with.
if constructor looks like so
public GenericClass( int id ) ** assuming the class uses an int id(indentity field)
{
Load(id);
}
this way all classes pass in an id to create
from your program
Player p = new Player(1); <-- has an id of 1
so when you run this code. It processes the PlayerClass Contructor for custom stuff first. then calls the Generic contructor with the ID. The Generic class then load the data into the class
By the way the PlayerClass construction should look somthing like
public PlayerClass( int id ) : ( id ) {}
the second will call the base class's constructor with the id
Thats the basics of it. If thats the path your going, I can help you with the code inside Save and Load. But you need to understand what this accomplishes from a high level. And of course, if this is what your trying to do.
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
So by 1:1 you mean 1 player in the db equals one instance of player class in the code right?
So there would pretty much be a class for each table (or useful table that is not just foreign keys).
I was concerned by using stored procedures to insert and update since in C# i would have to sort out the paramaters for the variables, so if the db changed i would have to change the stored proc and have to change the code as well, wheras if i just used insert and update statements with ExecuteNonQuery of an SqlCommand object i would only have to change the code. At the moment in my Database class i am using an SqlDataAdapter to fill a DataSet and returning that dataset for SELECT statements. For other SQL statements i just execute the SQL.
As for the generic class, could this only handle like table, e.g. ones like you say that use an IDENTITY column or could it handle and table?
|
|
|
|
|
|
Not actually.
Typically you use a datareader that populates the class via reflection.
You can use Typed datasets. But thier huge, bulky, and have been proven to fail and force a re-write in the business world.
I hear they dont work well with workflows. I avoid them like the plague after seeing thier issues first hand a year ago.
But, its your code. And you still need to create an interface and .net comes with a class generator so You don't really save anytime using datasets.
The updating code is 10 lines or so.
Good luck with whatever you choose I would read about real world example with OMG www.omg.org they are a culmiation of 800+ enterprise size projects.
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
I'm not quite sure how i would go about populating a class via reflection with a datareader. Can you explain/give an example please?
I didn't know VS had class generators. What are these and how do i access them?
Thanks.
|
|
|
|
|
Send me an email to n_i_c_k_5_4_5_4 _at_ hot_mail ( minus the underscores of course )
I have a forum app ( hate php and we needed a forums webite for my world of warcraft guild ) that I did in c# thats easy to understand without too many tricks. It has forums and private mail enabled. If you send an email I can give you a password to it.
Send me an email and I'll send you the project and we can discuss what and how I did it. It doesn't use any ADO calls inside the pages.
-- theories --
But, as far as the DAL and BLL.
The class exists in the BLL.
The DAL will return a populated class.
But, this also depends on who you talk to also.
I come from a Java and C++ background and move towards SOA. So I don't believe in any ADO.NET calls anywhere but the DAL.
But, people that stem from VB or other scripting languages will use ADO.NET calls anywhere ( the UI, BLL, and DAL ) and think it's proper.
But, by definition it says that the business layer does not know about the source of the data. So if you do not know the source of data, then how could you use ADO? That is tied directly to the data.
One solution I have seen before is the create a class that extends the IDBConnection and what not. But, this is just a hack to disobey the rules of abstracting the data source which a DAL implies.
And also, since the DAL could be hitting xml, oracle, sql, excel, text files, and other sources I believe the DAL should query the data and based on the class requested populate what data it can. This way the BLL is never concerned with how it got there, it just knows its there. Which is the definition of an n-tiered application.
If you send me an email, I can write a small prototype demonstrating what I am trying to infer. And add a visio document that visually shows what I'm talking about. Tell me if you have visio in the email. If not the can paste the picture into a word document.
Hope this didnt confuse you.
Nick
-- modified at 10:49 Monday 31st July, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Hi, thanks, i have just sent you an email.
|
|
|
|