|
Hi All,
I've got the following lines in my button click handler.
if (!this.CheckObjectivesCheckBoxesValid())
{
var repeaterValidator = new CustomValidator();
repeaterValidator.IsValid = false;
repeaterValidator.ErrorMessage = "Please select at least one objective.";
Page.Validators.Add(repeaterValidator);
}
if (string.IsNullOrEmpty(this.txtDetails.Text) && string.IsNullOrEmpty(this.txtSuggestions.Text) && string.IsNullOrEmpty(this.txtSupportingEvidence.Text))
{
var requiredFields = new CustomValidator();
requiredFields.IsValid = false;
requiredFields.ErrorMessage = "You must include information in at least one of Details, Suggestions or Evidence";
Page.Validators.Add(requiredFields);
}
But the validation never seems to happen ...
Any ideas?
|
|
|
|
|
I tested your code and It's passing through IF and later adding to Validators it doesn't seem to display an Error Message.
You can have a Look to This CP Article[^]
|
|
|
|
|
Exactly what I thought.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Oh sorry, But you're 1.59 hrs late.
|
|
|
|
|
I'm always late... It's what happens when you live in a far western time zone.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi
I am having great issues trying to debug a page on a web application used internally on an intranet. When entering the page the "Security Information" Pop Up Box appears. The whole application is running under https.
To try and debug the issue, I have used Fiddler, and looked at the urls for every component, javascript, css, images, and user control components. Everything I have seen from Fiddler shows that the urls start with required https!
So, I am completely confused why this message should be shown - it appears everything the page is posted back.
Does anyone have any idea why this should be happening and/or have another tool that could help me?
Thanks
|
|
|
|
|
Try to check with firebug on the net, whether all the requests are going through SSL only.
|
|
|
|
|
We have checked with Fiddler that each request is https
|
|
|
|
|
hi
i have sql-server-2008 database that contain image field that hold picture.
i have pictureBox control in my webform.
how to put picture from database to pictureBox control ?
(i work with C# asp.net FW3.5)
can i get any sample code or program ?
thanks
|
|
|
|
|
|
please first search , if you dont result tell youre question
|
|
|
|
|
 i have this code to insert picture from database to image control:
string strQuery = "select Pic from MEN where id='1'";
SqlCommand cmd = new SqlCommand(strQuery);
Convert.ToInt32(Request.QueryString["ImageID"]);
cmd.Parameters.Add("1", SqlDbType.Int).Value = Convert.ToInt32(Request.QueryString["ImageID"]);
DataTable dt = GetData(cmd);
if (dt != null)
{
Byte[] bytes = (Byte[])dt.Rows[0]["Pic"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = dt.Rows[0]["PIC"].ToString();
Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0]["PIC"].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
and this:
private DataTable GetData(SqlCommand cmd)
{
DataTable dt = new DataTable();
String strConnString = "server=" + Server + ";database=" + DataBase + ";UID=" + UID + ";password=" + PASS + ";";
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
try
{
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
return dt;
}
catch
{
return null;
}
finally
{
con.Close();
sda.Dispose();
con.Dispose();
}
}
and this image:
<asp:image ID="Image2" runat="server" ImageUrl ="PhoneBook.aspx?ImageID=1"/>
but when I run this code I get "save picture on disk" and not insert to the image control
How to fix it ?
thanks
|
|
|
|
|
Would be a good answer if weren't already given 15 hours ago.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I feel it may require threaded discussion so I am moving the question here from Q&A.
Greetings everyone!
This may be a very simple question but I just can't get it working. Moreover Google doesn't seem to help me much (Or I still have a lot to improve on my searching skills. )
Let me explain the scenario:
This page is basically accessed by a user who has received some items and has to update this page accordingly.
I have a GridView bound to a DataTable. The GridView has a checkbox column, few databound columns and a TemplateColumn with a TextBox as ItemTemplate. The GridView has to be updated with two things -
a) By unchecking a checkbox, the user indicates that the particular item has not been received. So a flag indicating unreceived will be marked in the database.
b) The textbox in the template field will by default contain quantity sent for that particular item. The user can update it to actual quantity received.
After all edits are done, user clicks the save button and details (a) and (b) has to be updated to the database at a time.
What I have tried:
I save the initial GridView value in a ViewState. When the user clicks 'Save' I thought I will get the DataSource and compare the values and do a bulk update using a DataAdapter. But the DataSource is null (which is correct). I do not seem to be able to use things like DataTable.RowState for bulk update. How do I synchronize the GridView with the bound DataTable?
Please help me on how should I go about it.
Thanks!
|
|
|
|
|
I finally got that working. It was simple as I expected just that I didn't put much effort.
This is what I did:
User does the required edits (unchecking the checkbox for not received and editing the exact received quantity) an select 'Save'.
On Save button click,
I get the old data which was saved in ViewState into a datatable. Now I compare the GridView values to the values in DataTale (old values). If it has changed, I edit the value in the datatable. This changes the RowState of that row in the datatable.
The code seems like this:
DataTable dtChallanDtl = new DataTable();
dtChallanDtl = (DataTable)ViewState["ChallanDtl"];
int i = 0;
int ChallanRcvd = 1;
foreach (GridViewRow r in gvChallanDtl.Rows)
{
CheckBox chk = (CheckBox)r.FindControl("CheckSelect");
TextBox txt = (TextBox)r.FindControl("txtRecvQty");
if (chk.Checked == true)
{
dtChallanDtl.Rows[i]["Received"] = 1;
}
else
{
ChallanRcvd = 2;
}
if (dtChallanDtl.Rows[i]["RecvQty"].ToString() != txt.Text)
{
dtChallanDtl.Rows[i]["RecvQty"] = txt.Text;
dtChallanDtl.Rows[i]["Received"] = 2;
ChallanRcvd = 2;
}
i++;
}
Here, the variable 'ChallanRcvd' represents the database column which stores the received status of the challan. 0-not received, 1-received, 2-partailly received.
Now I do a bulk update using SqlDataAdapter's Update method.
The important things here are:
SqlDataAdapterObj.UpdateBatchSize = 4; //how many records need to be updated in each batch.
SqlCommandObj.UpdatedRowSource = UpdateRowSource.None; //how command results are applied to the datarow.
After all parameters are supplied, call SqlDataAdapterObj.Update(dtChallanDtl);
I posted this question here because I couldn't find any example on bulk edit using GridView bound to a datatable.
I hope it helps someone.
Regards
Test
|
|
|
|
|
Following code does not handle columns that start with + e.g.
'+923339933886' is not rendered well(some kind of charmap characters shown).
here is what it shows.(꺻퍎)
HtmlForm form = new HtmlForm();
string attachment = "attachment; filename=Employee.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form.Controls.Add(gvEmployee);
this.Controls.Add(form);
form.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
Please let me know what is the changes required in this code.
|
|
|
|
|
Hi, I think you should set the encoding to UTF-8.
Have a look at this thread which has answer(4th post by user lionscub).
Export DataGrid To Excel[^]
Free attachment
You may need this too.(For Ex, large numbers get converted to the (ugly) x.xxxxxxE-yy syntax. )
Datagrid to Excel Formatting Tip[^]
|
|
|
|
|
|
Hi
I am using Asp.net and ajax tool kit 3.0.30.
WHen i dynamically add TabPanels in Tabcontainer control it loads and displays fine.But when i try to change Tab it gives javascript error "Specified argument was out of the range of valid values". I have searched that problem and come to know that there is problem in ajaxtoolkit so i have updated the source code of ajax tool kit according to informtin given in "http://siderite.blogspot.com/2007/07/fixing-tabcontainer-to-work-with.html". But problem is still i have to recreate Tabs at page load.Is it not possible for tabcontainer to maintain its view state and i have not to dynamically add tabs on page load again ?(When Page post back).
I am using tab container in Usercontrol.
|
|
|
|
|
|
hi friends
how can i scan a photo or a document with asp.net project??
M.Alizadeh
|
|
|
|
|
You can't unless you use some ActiveX component which operates outside the browser security sandbox.
|
|
|
|
|
Are you trying to scan the webpage/image at client machine?
|
|
|
|
|
i want use scanner from my program.. i need a user interface for scanner program in control pannel
M.Alizadeh
|
|
|
|
|