|
Hi,
1)I am having one dropdownlist,one textbox and one submit button shown below
<asp:dropdownlist autopostback="true" cssclass="textboxGQ_New" width="200px" id="drp_Category" runat="server" onselectedindexchanged="drp_Category_SelectedIndexChanged">
<asp:listitem value="">Select Category
<asp:listitem value="Samp1">Sample1
<asp:listitem value="Samp2">Sample2
<asp:listitem value="Samp3">Sample3
<asp:listitem value="Samp4">Sample3
2)My isssue is If i select Sample1 or Sample3 from the dropdownlist the text box should fire requiredfield validation i.e it has to show an alert as plz enter text in the textbox.
3)If i select Sample2 or Sample3 from the dropdownlist the text box should not fire requiredfield validation i.e it should not fire any validation and should accept null value while submit button is clicked
4)plz provide the sample code for the above issue..i want server-side code..i don't want Using JavaScript funtions....
|
|
|
|
|
shaik_mr wrote: plz provide the sample code for the above issue..i want server-side code..i don't want Using JavaScript funtions
Where shall I sent the invoice for writing this for you?
only two letters away from being an asset
|
|
|
|
|
shaik_mr wrote: ..i want server-side code..i don't want Using JavaScript funtions....
Well, if you want server side code, you don't even need a 'validator', unless you're using that overall framework. And the code is so trivial, that I don't see why you'd have trouble at least trying to write it, and posting a more specific question if you get stuck.
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.
|
|
|
|
|
Hello,
I want submit button to fetch different query results from the database. So I have implemented which query to execute inside the SubmitButton_Click function/method. But it's not working as I have desired....it's fetching one query every time.
To give you a brief idea, in my .aspx I have 2 dropdown lists (1 to select which query to run and another one to select which patient number should I pull from the DB), 1 text box which contains date field. I have kinda found what's causing the problem....but don't know how to solve it. Somehow from the drop down list "ANY" is selected all the times.....no matter what I select from the second dropdown list. Any suggestion would be really helpful.
The code is as follows:
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
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;
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.TextBox date_TB;
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_QUER Y;
getMLNO();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
BuildQueryForm(); [This function/method is calling the submit button function]
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.exportLinkbutton.Click += new System.EventHandler(this.exportLinkbutton_Click);
this.Load += new System.EventHandler(this.Page_Load); [after the data is pulled from the DB the export to excel button should show up, so I have implemented this here]
}
#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()
{
OleDbConnection connection = new OleDbConnection(HIV.Database.DataConstants.CONNECT ION_STRING);
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand("SELECT DISTINCT re_MLNO FROM ml_hiv_status", connection);
DataSet ds = new DataSet();
adapter.SelectCommand = command;
if (adapter.Fill(ds) > 0)
{
int adp= adapter.Fill(ds);
DataView view = ds.Tables[0].DefaultView;
mlno_DDL.DataSource = view;
mlno_DDL.DataValueField="re_MLNO";
mlno_DDL.DataBind();
resultsLabel.Visible= true;
mlno_DDL.Items.Insert(0, "ANY");
}
connection.Close();
}
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=="Resista ntL")
{
resultsLabel.Visible= true;
resultsLabel.Text ="You Have selected"+ Specific_Query_DDL.SelectedItem.Value;
}
if(Specific_Query_DDL.SelectedItem.Value=="Negativ eL")
{
resultsLabel.Visible= true;
resultsLabel.Text ="You Have selected"+ Specific_Query_DDL.SelectedItem.Value;
}
if(Specific_Query_DDL.SelectedItem.Value=="Positiv eL") [The problem is here in this if else block]
{
if(mlno_DDL.SelectedItem.Value=="ANY")
{
executePositiveListQuery_ANY(); [All the time this one is called but...]
}
else
{
executePositiveListQuery_MLNO(mlno_DDL.SelectedIte m.Value); [...I want this method to be called as well when I am selecting a specific patient number]
}
}
if(Specific_Query_DDL.SelectedItem.Value=="DeadL")
{
resultsLabel.Visible= true;
resultsLabel.Text ="You Have selected"+ Specific_Query_DDL.SelectedItem.Value;
}
}
public void executePositiveListQuery_ANY()
{
string sql= "SELECT DISTINCT re_MLNO FROM ml_hiv_status WHERE (re_HIV1_Status=1 AND re_HIV2_Status=1)";
try
{
OleDbConnection connection = new OleDbConnection(HIV.Database.DataConstants.CONNECT ION_STRING);
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand(sql, connection);
DataSet ds = new DataSet();
adapter.SelectCommand = command;
int count = adapter.Fill(ds);
if (count > 0 && count <= 200)
{
DataView view = ds.Tables[0].DefaultView;
resultsDatagrid.DataSource = view;
resultsDatagrid.DataBind();
resultsDatagrid.Visible = true;
resultsLabel.Text = count.ToString() + " results found.";
resultsLabel.Visible = true;
exportLinkbutton.Visible = true;
}
else if (count> 200)
{
DataView view = ds.Tables[0].DefaultView;
resultsDatagrid.DataSource = view;
resultsDatagrid.DataBind();
resultsDatagrid.Visible = false;
resultsLabel.Text = "More than 200 results found. Please Click the Export to Excel Link to Download the Results.";
resultsLabel.Visible = true;
exportLinkbutton.Visible = true;
}
else
{
resultsLabel.Text = "No results found.";
resultsLabel.Visible = true;
exportLinkbutton.Visible = false;
resultsDatagrid.Visible = false;
}
connection.Close();
}
catch(Exception ex)
{
message.InnerHtml = "SQL: " + sql + "<p></p>" + ex.ToString();
}
}
public void executePositiveListQuery_MLNO(string selected_MLNO)
{
resultsLabel.Text ="You Have selected"+ selected_MLNO;
}
private void exportLinkbutton_Click(object sender, System.EventArgs e)
{
resultsDatagrid.Visible = true;
DataGridItem tblGrid=resultsDatagrid.Items[0];
ArrayList alLinks= new ArrayList();
TableCell TC;
LinkButton LB;
for(int i=0; i<tblGrid.Cells.Count - 1; i++)
{
TC=tblGrid.Cells[i];
if(TC.Controls.Count> 0)
{
LB=(LinkButton)TC.Controls[0];
resultsDatagrid.Items[0].Cells[i].Controls.Clear();
resultsDatagrid.Items[0].Cells[i].Text=LB.Text;
}
else
LB=new LinkButton();
alLinks.Add(LB);
}
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
resultsDatagrid.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
resultsDatagrid.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
for(int i=0; i<tblGrid.Cells.Count - 1; i++)
{
LB = (LinkButton)alLinks[i];
resultsDatagrid.Items[0].Cells[i].Controls.Add(LB);
}
}
}
}
Please help! Thanks to everyone who give their time and energy to solve this.
|
|
|
|
|
I'm not a C# guy, but it sure seems like you call getMLNO on every page_load which then adds in the "Any" item into the dropdownlist which overrides what the user selected. Put that in a If Not Ispostback then (C# equivalent for you) you should be all set.
|
|
|
|
|
I don't know how to thank you enough! all these times I am wondering why this is happening!! But I understood that something is wrong with the post back condition and the way I am calling getMLNO() cause every time I refresh the page or hit submit the MLNO dropdown list was getting refreshed as well and thus selecting ANY every time....
|
|
|
|
|
My pages worked fine, when they were located on the root of my project. When I moved them to folders, in preparation of doing roles/permissions, I had some issues that I worked through.
Dropdownlists with AutoPostBack = "False" on the page work fine. But, I cannot seem to get past an issue with a dropdownlist that does a postback. I am getting an error: Sys.Webforms.PageRequestManagerServerErrorException. The status code returned from the server was: 404.
I think the problem is related to AutoPostBack and UpdatePanel, but I don't know how to fix it. If someone could point me in the right direction, I would appreciate the assistance.
|
|
|
|
|
Going to need a little bit more then this to go off of, like some code.
|
|
|
|
|
dear friends...
i am designing a new portal there i need to generate a personal url to every people when joined. then he will use that url to make others will join under him. so plz kindly give me suggestions.
thank you to all in advance.
|
|
|
|
|
Read about URL rewriting.
|
|
|
|
|
I'm hoping someone has a simple example they can point me to. I am trying to get a web page to be able to use a DLL for local printing on some administrators pages. All appears to be working fine until I have the DLL try to access the same MS SQL database that the rest of the website is accessing. Then, I get the SQL Permission error.
I've tried the assert method to get around this, but no luck. I've been trying to create the DLL as a strongly named assembly and get it installed in the GAC on the administrators' computers, but my page can no longer access the assembly after it is strongly named. I suspect I am missing something simple in the object tag on the page, but cannot seem to find what that is.
Currently, I am using:
<object id="PrintTag" height="31" width="177" classid="bin/<dllname>.dll#<classname>">
on the page. This works if the dll is not strongly named and my calling function within the Javascript works, except for the SQL Permission error. When I strongly name the dll and try it, I get an undefined error. Makes sense that the <classname> has changed, but I can't seem to find what it has been changed to to call.
Any thoughts?
|
|
|
|
|
Hi guys...,
I am trying to show advertisement page in my site...,
i have more than one image using adrotator control i am displaying it in alternatively...,
now my clients giving script files...,its possible to show the script files also using the adrotator control?,
if its not possible give me some other way...,
how to achieve it...,
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
hi i want to bind treeview structure ..
i m geting data from database to dataset
this is my sql statement-- select thd.sSubject,sthd.sMembername,sthd.sSubincadNo,thd.sIncadNo from theard thd , subtheard sthd where sthd.sSubincadNo = sthd.sSubincadNo and sthd.sIncadNo = thd.sIncadNo and thd.FkiIncidentId = '1001'
and this statement storing into ds;
so now i want to bind ds to treeview..
would u tell me how can i do this.
if ur have any queries free feel to ask
try and try untill reach success..
|
|
|
|
|
Rajeshwar Code- Developer wrote: if ur have any queries free feel to ask
I thought you were the who has queries?
|
|
|
|
|
i m sorry dude but if anyone know reply me.
try and try untill reach success..
|
|
|
|
|
I need to access a perticular cell via javascript . I know how to access the whole gridview , but I dont know how to do it for a particular cell...
Is it possible?
|
|
|
|
|
can you please explain your question details. whats your exact requirement or what do you want to do?
so that can i answer proper.
Regards
Keyur Satyadev
|
|
|
|
|
|
thanks, but I think I didn't describe my problem well.
I need to capture a right-mouse-click on a gridview's cell and than to change it's color - using javascript
|
|
|
|
|
Are you able to capture left click on the cell?
|
|
|
|
|
no...I'm only able to capture a click on the whole grid view.
I want to fint out if it possible to capture a particular cell mouse click
|
|
|
|
|
Try this code
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add("onclick", "return jsClickFunction(this);");
}
}
Instead of e.Row.Cells[0] you need to loop through all cells of a row.
Try this and you shall be able to capture each cell click event.
HTH
|
|
|
|
|
Hi Experts,
I am sending mail using my application. It is working fine with My company id and Gmail Id. when I keep my client Id it is showing duplicate mails including time received.
Any one can help me why it is showing duplicate mails only to my client Id.
Problem not reproduced with My Gmail Id and My company Id.
Thanks
|
|
|
|
|
Hi Experts,
I am sending mail using my application. It is working fine with My company id and Gmail Id. when I keep my client Id it is showing duplicate mails including time received.
Any one can help me why it is showing duplicate mails only to my client Id.
Problem not reproduced with My Gmail Id and My company Id.
Thanks
|
|
|
|
|
I'm using a cascading dropdownlist using three tables. the code below works fine if my primary keys are numeric(integer) but my business rules want the primary keys to be alphernumeric(string).
[WebMethod]
public CascadingDropDownNameValue[] GetColors(string knownCategoryValues, string category)
{
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
int colorId;
if (!kv.ContainsKey("Model") || !Int32.TryParse(kv["Model"],out colorId))
{
return null;
}
dsModelColorsTableAdapters.ModelColorsTableAdapter adapter = new dsModelColorsTableAdapters.ModelColorsTableAdapter();
dsModelColors.ModelColorsDataTable colors = adapter.GetColorsByModelId(colorId);
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
foreach (DataRow dr in colors)
{
values.Add(new CascadingDropDownNameValue((string)dr["ColorName"], dr["ColorID"].ToString()));
}
return values.ToArray();
}
How do I use my string primary key using the above code?
Please help an ajax technology adict.
ML Lingwati
|
|
|
|