|
sashidhar wrote: If this is not ur answer sry
No, it's not.
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.
|
|
|
|
|
The answers you are getting are wrong.
Server events are a mirage. They get replaced with client side events. You need to write an OnClientClick event if you want to have javascript run in your code. ASP.NET is going to replace anything else you write, with an onclick, which is the proper HTML that needs to be written for all the browsers on earth, so if you write it, you're fighting ASP,NET
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 m using C#.net app with access database
i have a employee table with the following columns
Sr.NO(PK), Employee_ID, Category_ID, Image_ID, Description
i want to display the records on the basis of category selected from drop down and then following that Category ID i want to pick the relevant Employee_ID and want to display the name from another table on the basis of that ID
any idea how and where to display that record ??
|
|
|
|
|
First of all you need to bind one Dropdown list with the Category field. When user select the category you need to execute another query to pickup the name from DB and bind it wherever you want.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
ddHospitalName.DataSource = select_result
ddHospitalName.DataBind()
and DataTextField ="hospitalName" in designer
Thanks,
Amit PAtel
|
|
|
|
|
Please help me.
I want employee photo store into SQL database.
And retriev the photo from database and display a photo in IE.
Please give me exact coding in VB.
Thanking You,
abglorie
|
|
|
|
|
i have a code in C# for access database
make an upload folder in your project file
Label1.Text = Server.MapPath(@"~/Upload/" + FileUpload1.FileName.ToString());
FileUpload1.SaveAs(lbl_path.Text);
Image1.ImageUrl = "~/Upload/" + FileUpload1.FileName;
Label1.Text = FileUpload1.FileName;
and now through insert command save Label1.Text into your database
and for retrieving the picture
and for retrieving the picture
use select command
give id of that row in some textbox
cmd=new oledbcommand("Select Image from Images where ID='"+textbox1.text+"'",con);
rd=cmd.executereader();
if(rd.read())
{
textbox2.text=rd["Image"].tostring();
Image1.ImageUrl=@"~\upload\"+textbox2.text;
}
hope it works
|
|
|
|
|
Hello All,
I have really a simple question, what is the best way (in your opinion) to provide an AJAX wizard like interface?
Now I have implemented this functionality in several different ways in the past but I just want to get the input of some other people on different methods of getting this done and their advantages / disadvantages.
Really what I'm looking for is something built using AJAX that will allow me to have several steps that are processed asynchronously.
All thoughts and ideas are welcome.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi, I have been using Virtual path in Web site model successfully and recently i am thinking about upgrading my websites to web applications and here I got a confusion. I know, Web applications are pre compiled and must be compiled in a DLL and then deployed in the production server. If I have virtual file which is ASPX page with inline code, will that work in Web Application as the inline codes wont be compiled to the dll in the compile time, right ?
|
|
|
|
|
hello sir '
my problem is that i am trying to convert multiline textbox text to gif format. every thing works fine except the text which is to be converted convert only first line .
i think it is converting text box text as a single line
any suggestion plz
here is my code
Bitmap b = new Bitmap(330,TextBox1.Text.Length, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(b);
string message;
g.Clear(Color.Yellow);
message = TextBox1.Text;
StringFormat format = new StringFormat();
int alignment = 1;
if (alignment == 1)
{
format.Alignment = StringAlignment.Near;
}
format.LineAlignment = StringAlignment.Center;
g.DrawString(TextBox1.Text, new Font("Kruti Dev 010", 12, FontStyle.Regular), new SolidBrush(Color.Black),new PointF(2.5F,.5F) ,format);
Response.ContentType = "image/gif";
b.Save(Server.MapPath("IMG\\"+img+".gif"), ImageFormat.Gif);
b.Dispose();
Response.Write("file uploaded Successfully");
}
|
|
|
|
|
monu_khan wrote: TextBox1.Text.Length
This is more than a little insane. You need to use MeasureString to get a width and height.
monu_khan wrote: Graphics g = Graphics.FromImage(b);
Why not use a using statement, instead of leaking resources ?
monu_khan wrote: new Font("Kruti Dev 010", 12, FontStyle.Regular)
Another leak, plus if you change the font, it means you need to measure the string for that font.
Although you're using ASP.NET, this question has nothing to do with ASP.NET, it's about some basic graphics work. Why do you waste server space by saving a string a a bitmap instead of as text ?
monu_khan wrote: int alignment = 1;
if (alignment == 1)
Bizarre.
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.
|
|
|
|
|
Dear all,
I am having problem with placing the proper condition inside the postback method. I am trying to do the following:
1. There are 2 dropdown lists in my program.
2. I have two DropDownLists databound on the webform. The autopostback of the first dropdown list control is set to true. The contents of the first dropdown list is hardcoded. The contents of the second depend on the selected item in the first. In other words: The selectedvalue of the first DropDownList is passed as a parameter for the query at the basis of the second DropDownList's datasource. And this works: Whenever I click on an item in the first DropDownList, the dependant items are shown in the second DropDownList.
3. If I click submit then the specific rows from the DB will be pulled based on the values selected from dropdown list 1 and dropdown list 2.
Problem: In the postback method I think all the times the "ANY" MLNO is selected instead of selecting a specific value from the dropdown list 2. And that's why always all the values are pulled from the DB.
The code is as follows:
Code:
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Globalization;
namespace HIV
{
public class run_specific_query : System.Web.UI.Page
{
protected HIV.Controls.NavMenu navMenu;
protected HIV.Controls.NavSubMenu navSubMenu;
protected System.Web.UI.HtmlControls.HtmlGenericControl message;
protected System.Web.UI.WebControls.Label resultsLabel;
protected System.Web.UI.WebControls.DropDownList Specific_Query_DDL;
protected System.Web.UI.WebControls.DropDownList mlno_DDL;
protected System.Web.UI.WebControls.CompareValidator dateValidator;
protected System.Web.UI.WebControls.DataGrid resultsDatagrid;
protected System.Web.UI.WebControls.Button submitButton;
protected System.Web.UI.WebControls.Label data_src;
protected System.Web.UI.WebControls.LinkButton exportLinkbutton;
private void Page_Load(object sender, System.EventArgs e)
{
navMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
navSubMenu.SelectedMainItem = HIV.Controls.NavMenu.MainItems.QUERY;
navSubMenu.SelectedSubItem = HIV.Controls.NavSubMenu.SubItems.RUN_SPECIFIC_QUERY;
if (this.IsPostBack)
{
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);
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
BuildQueryForm();
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.exportLinkbutton.Click += new System.EventHandler(this.exportLinkbutton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected void BuildQueryForm()
{
try
{
this.submitButton.Click += new System.EventHandler(this.submitButton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
catch(Exception e)
{
message.InnerHtml = "Exception: " + e.ToString();
}
}
private void getMLNO(string selectedvalue)
{
if(selectedvalue=="ResistantL")
{
string sql= "SELECT re_MLNO, MAX(re_SpecimenDate)-MIN(re_SpecimenDate) AS DaysSeronegative FROM ml_hiv_status WHERE (re_HIV1_Status=0) GROUP BY re_MLNO";
OleDbConnection connection = new OleDbConnection(HIV.Database.DataConstants.CONNECTION_STRING);
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand(sql, connection);
DataSet ds = new DataSet();
adapter.SelectCommand = command;
if (adapter.Fill(ds) > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
if(Convert.ToInt32(r["DaysSeronegative"]) < 2555)
{
r.Delete();
}
}
DataView view = ds.Tables[0].DefaultView;
mlno_DDL.DataSource = view;
mlno_DDL.DataValueField="re_MLNO";
mlno_DDL.DataTextField = "re_MLNO";
mlno_DDL.DataBind();
resultsLabel.Visible= true;
mlno_DDL.Items.Insert(0, "ANY");
}
connection.Close();
}
if(selectedvalue=="NegativeL")
{
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);
DataSet ds = new DataSet();
adapter.SelectCommand = command;
if (adapter.Fill(ds) > 0)
{
foreach (DataRow r in ds.Tables[0].Rows)
{
if(Convert.ToInt32(r["hivNeg"]) != 0)
{
r.Delete();
}
}
DataView view = ds.Tables[0].DefaultView;
mlno_DDL.DataSource = view;
mlno_DDL.DataValueField="re_MLNO";
mlno_DDL.DataTextField = "re_MLNO";
mlno_DDL.DataBind();
resultsLabel.Visible= true;
mlno_DDL.Items.Insert(0, "ANY");
}
connection.Close();
}
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void submitButton_Click(object sender, System.EventArgs e)
{
if(Specific_Query_DDL.SelectedItem.Value=="default")
{
resultsLabel.Visible= true;
resultsLabel.Text ="Please select a specific query from the dropdown list";
exportLinkbutton.Visible = false;
}
if(Specific_Query_DDL.SelectedItem.Value=="ResistantL")
{
if(mlno_DDL.SelectedItem.Value=="ANY")
{
executeResistantListQuery_ANY();
}
else if(mlno_DDL.SelectedItem.Value!="ANY")
{
executeResistantListQuery_MLNO(mlno_DDL.SelectedItem.Value);
}
}
if(Specific_Query_DDL.SelectedItem.Value=="NegativeL")
{
if(mlno_DDL.SelectedItem.Value=="ANY")
{
executeNegativeListQuery_ANY();
}
else if(mlno_DDL.SelectedItem.Value!="ANY")
{
executeNegativeListQuery_MLNO(mlno_DDL.SelectedItem.Value);
}
}
}
Thank you all who will try to solve the problem. To me it seems that the the second dropdown list is getting refreshed everytime I am posting the page back/submit and that's why "ANY" is getting selected and thus it's pulling all the data. This is not the whole code, this is only the part I thought might be useful to suggest any solution. Though other people might feel it's useless(!).
|
|
|
|
|
Yes.. the culprit is your page load method..
Just for every post-back, even when submit button is clicked, ASP.NET first calles Page_Load and after its execution it calles the general event handler.
Just omit the lines
if (this.IsPostBack)
{
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);
}
}
and place them in Listbox1_selectedIndexChanged event.
I thin as that is called specific when postback occurs on selected indexchanged event, the submit will not load the 2nd dropdown onsubmit.
The problem will be fixed then...
|
|
|
|
|
Thank you Mr. Sur. I knew that the culprit is the page load method.. but didn't know how to populate the second dropdown list without the pageload.
Should I put the code you mentioned exactly inside the Specific_Query_DDL_selectedIndexChanged function ? And should I call that function inside the page_Load function?
Please suggest. Thanks in advance.
|
|
|
|
|
No..
You dont need to call selectedIndexChanged function from page_load , it will automatically been called. Rather than that, you just write
if(IsPostBack) return;
in the page_load, to eliminate any code to be executed in page_load during postbacks.
When the selectedIndexChanged is posting back the page to the server, it always calls the Page_Load event first, then its original event handler. So you just need to suppress page_load during event calls.
Hope you got it clearly.
|
|
|
|
|
Abhishek Sur wrote: if(IsPostBack) return;
in the page_load, to eliminate any code to be executed in page_load during postbacks.
This is nuts. It may work for the code he has today, but it's a terrible paradigm. Why should one not write code in page load that needs to run every time ? Instead, put if (!IsPostback) blocks around the specific code you need to stop running
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.
|
|
|
|
|
|
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
|
|
|
|