|
|
Yes, this is still far too much code to be posting.
You don't need to be reloading the data every time, unless you turn off viewstate. If you do need to, do it in page_prerender, that's the right place to do it anyhow. Then it will happen AFTER your event fires.
skhan17 wrote: if(Specific_Query_DDL.SelectedItem.Value=="default")
Hard coded strings are a bad idea. can't you store an enum or something in the value ?
skhan17 wrote: string sql= "SELECT re_MLNO,sum(re_HIV1_Status) AS hivNeg, MAX(re_SpecimenDate)- MIN(re_SpecimenDate) AS DaysSeronegative FROM ml_hiv_status GROUP BY re_MLNO";
OleDbConnection connection = new OleDbConnection(HIV.Database.DataConstants.CONNECTION_STRING);
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand(sql, connection);
SQL in the presentation layer is always a sign of no design. I'd fire anyone who presented code like this to me.
skhan17 wrote: if(Specific_Query_DDL.SelectedItem.Value=="ResistantL")
{
getMLNO(Specific_Query_DDL.SelectedItem.Value);
}
if(Specific_Query_DDL.SelectedItem.Value=="NegativeL")
{
getMLNO(Specific_Query_DDL.SelectedItem.Value);
}
Hard coded strings are still bad. And, have you never heard of the || operator ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have a user control with two input boxes. The onkeyup calls a function. The function works but the problem is when I have two of these user controls on a page. When document.getElementById("Text2").focus() executes for the second user control it puts the focus on Text2 in the first user control. How do I reference Text2 so that the focus is place on the correct Text2?
function TimeEntryHoursOnClick(theTextbox)
{
if (event.keyCode == 38)
theTextbox.value = parseFloat(theTextbox.value) + 1
if (event.keyCode == 39)
document.getElementById("Text2").focus();
}
|
|
|
|
|
You need to use the ClientID to get the proper DOM element. Try looking here[^]
only two letters away from being an asset
|
|
|
|
|
The code cannot find Text2. This line returns null. Any ideas why?
document.getElementById("ctl00_ContentPlaceHolder1_TimeEntryBox1_Text2");
Here is the HTLM.
<div id="ctl00_ContentPlaceHolder1_TimeEntryBox1_Panel1" style="border-color:#7F9DB9;border-width:1px;border-style:Solid;width:89px;">
<input id="Text1" name="Text1" onkeyup="TimeEntryHoursOnClick(this)" onblur="TimeEntryHoursOnBlur(this)" style="border: 0px none #FFFFFF; width: 12px; " type="text" maxlength="2" />
:
<input id="Text2" name="Text2" type="text" onkeyup="TimeEntryMinutesOnClick(this)" onblur="TimeEntryMinutesOnBlur(this)" style="border: 0px none #FFFFFF; width: 12px" maxlength="2" />
<input type="hidden" id="ctrlPrefix" name="ctrlPrefix" value='ctl00_ContentPlaceHolder1_TimeEntryBox1_'>
</div>
|
|
|
|
|
Have you tried debugging the JavaScript?
only two letters away from being an asset
|
|
|
|
|
getElementById is a javascript function that finds one element. If the ID of the textbox is Text1 when rendered to the client browser (I mean if you see id of your input as Text1 when you see Source from the browser), just use
var element = document.getElementById("Text1");
rather than
var element = document.getElementById("ctl00_ContentPlaceHolder1_TimeEntryBox1_Text2");
If you want to find the div, you can do so using
var divelement = document.getElementById("ctl00_ContentPlaceHolder1_TimeEntryBox1_Panel1");
Always remember, you can mention only those elements which are rendered to the client. ASP.NET server side Ids are different than what is rendered in the client side. Use ClientID than ID for any server control to get the actual ID generated in the client, and always call this ID through JAVASCRIPT.
Hope you got it.
|
|
|
|
|
Ok thanks for the info, but how would I set the focus to Text2 in ctl00_ContentPlaceHolder1_TimeEntryBox2_Panel1?
<div id="ctl00_ContentPlaceHolder1_TimeEntryBox1_Panel1" style="border-color:#7F9DB9;border-width:1px;border-style:Solid;width:89px;">
<input id="Text2" name="Text2" type="text" onkeyup="TimeEntryMinutesOnClick(this)" onblur="TimeEntryMinutesOnBlur(this)" style="border: 0px none #FFFFFF; width: 12px" maxlength="2" />
<input type="hidden" id="ctrlPrefix" name="ctrlPrefix" value='ctl00_ContentPlaceHolder1_TimeEntryBox1_'>
</div>
<div id="ctl00_ContentPlaceHolder1_TimeEntryBox2_Panel1" style="border-color:#7F9DB9;border-width:1px;border-style:Solid;width:89px;">
<input id="Text2" name="Text2" type="text" onkeyup="TimeEntryMinutesOnClick(this)" onblur="TimeEntryMinutesOnBlur(this)" style="border: 0px none #FFFFFF; width: 12px" maxlength="2" />
<input type="hidden" id="ctrlPrefix" name="ctrlPrefix" value='ctl00_ContentPlaceHolder1_TimeEntryBox2_'>
</div>
|
|
|
|
|
Hi
I am using sqlhelper class for dataaccess.I am retriving records from view.The records more than 20,000.In this case i got timeout expired.i increase the connectiontimeout is 120sec.If any solution to solve this problem.
your's subbu
|
|
|
|
|
Try setting commands timeout property to a higher value
|
|
|
|
|
ncsubbu wrote: The records more than 20,000.In this case i got timeout expired.
Why you are trying to retreive this much of data ? Try to use some filter criteria to minimize the records.
If you have enoung time out, check the process in backend. Where its taking time, Use Breakpoint and Debug to find it out. Or Profile your Query.
One more suggestion, please don't hit database frequently for this. It will impact your Performacne badly. Try to use caching for improve the performance !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Try creating an index on the table columns. that should help increase performance.
|
|
|
|
|
While that may work, it doesn't address the insanity of a web page asking for 20,000 records...
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
In Asp.Net 3.5 In One Project 3 solutions are there One is BOl, DAl , Presentation Layer how can access through them. plz send me code.
|
|
|
|
|
make the object of class of BLL and DAL and use object to call method.
refer following link
Thanks
|
|
|
|
|
vaishali.terse wrote: In Asp.Net 3.5 In One Project 3 solutions are there One is BOl, DAl , Presentation Layer how can access through them.
This is not Only the case of ASP.NET 3.5, this is the normal 3 Tier Architecture for Application Development.
UI/Presentation layer will interact with BAL and BAL will Interact with DAL .
DAL will directly Communicate with Datbase, and BAL should contain the Object of DAL Class. And You should call BAL Object from your UI.
Here is one of the good Example for you,
3-Tier Application with ASP.NET and C#[^]
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
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 _Default : System.Web.UI.Page
{
private void calDate_SelectionChanged(object sender, System.EventArgs e)
{
control.Value = calDate.SelectedDate.ToShortDateString();
Response.Write("<script language='javascript'>window.returnValue='" + calDate.SelectedDate.ToString("dd/MM/yyyy") + "';window.close();</script>");
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
private void calDate_SelectionChanged(object sender, System.EventArgs e)
{
control.Value = calDate.SelectedDate.ToShortDateString();
Response.Write("<script language='javascript'>window.returnValue='" + calDate.SelectedDate.ToString("dd/MM/yyyy") + "';window.close();</script>");
}
}
protected void calDate_SelectionChanged1(object sender, EventArgs e)
{
Response.Write("<script language = "javascript">opener.document.getElementById(Request.QueryString["ID"]).value='" + (Calendar1.SelectedDate) + "'; self.close();</script>");
}
}
can anyone help me out wid this code.i just want to generate a popup calendar.
this piece of code is throwing some errors.
i got this code from http://www.codeproject.com/Messages/2246753/calendar-in-popup-window.aspx[^]
plz help me to use this
|
|
|
|
|
Why Dont You Use Calendar Exrender Controlinstead of script .If this is not your Answer Sorry
|
|
|
|
|
can u give me some idea of that
|
|
|
|
|
Can you tell me what is you exact requirment ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
i want to have a calendar inside a dropdown list or attached to a text box.can u help me
|
|
|
|
|
|
Hello Friends,
I'm generating a xml file from sql table in asp.net(c#). Here is my code given below
using (SqlConnection mCon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
{
mCon.Open();
string strsql = "Select * From MakeTable Where Active=1 For XML Auto,ELEMENTS";
//string strsql = "Select * From MakeTable Where Active=1 ";
SqlCommand mDataCom = new SqlCommand();
mDataCom.Connection = mCon;
mDataCom.CommandText = strsql;
mDataCom.CommandTimeout = 15;
DataSet ds = new DataSet();
XmlReader xmlReader = null;
xmlReader = mDataCom.ExecuteXmlReader();
ds.ReadXml(xmlReader);
ds.DataSetName = "Halo";
ds.WriteXml("F://Manoj//Autoneed/Rough//XMLFile2.xml");
}
but it's giving me output as shown here
<MakeTable>
<MakeID>10</MakeID>
<MakeNameID>36</MakeNameID>
<MakeYear>2009</MakeYear>
<Active>1</Active>
</MakeTable>
but if i run my sql command in sql then it's giving me following records
as shown below
<MakeTable>
<MakeID>1</MakeID>
<MakeNameID>17</MakeNameID>
<MakeYear>2009</MakeYear>
<Active>1</Active>
</MakeTable>
<MakeTable>
<MakeID>3</MakeID>
<MakeNameID>17</MakeNameID>
<MakeYear>2006</MakeYear>
<Active>1</Active>
</MakeTable>
<MakeTable>
<MakeID>4</MakeID>
<MakeNameID>17</MakeNameID>
<MakeYear>2007</MakeYear>
<Active>1</Active>
</MakeTable>
<MakeTable>
<MakeID>5</MakeID>
<MakeNameID>17</MakeNameID>
<MakeYear>2005</MakeYear>
<Active>1</Active>
</MakeTable>
<MakeTable>
<MakeID>7</MakeID>
<MakeNameID>17</MakeNameID>
<MakeYear>2004</MakeYear>
<Active>1</Active>
</MakeTable>
can anybody let me know how can i get this output or where and what change i should make in my code or sqlcommand
|
|
|
|
|
What happens if you try this?
while (xmlReader.Read())
{
ds.ReadXml(xmlReader);
ds.DataSetName = "Halo";
ds.WriteXml("F://Manoj//Autoneed/Rough//XMLFile2.xml");
}
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
it didn't dawn on me at first glance that you had a dataset in there...so I don't think the above would work. Since it appears to be coming back from the SQL server correctly, what if you avoided the DataSet all together and just saved it straight to a file?
TextWriter tw = new StreamWriter("output.xml");
while (datareader.read())
{
tw.WriteLine(datareader.ToString());
}
tw.Close();
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|