|
|
Dear Ravi,
Matter here is not about storing a connection string in a safe place.
Please get into the question properly.
|
|
|
|
|
Hiren Solanki wrote: Please get into the question properly.
Of-course I did it before posting my answer.
Hiren Solanki wrote: Matter here is not about storing a connection string in a safe place.
He just want to know how to create a connection for Web programming and I just referring him Links with valuable advice whatever, thanks for your advice.
|
|
|
|
|
Dear Friends,
I want to open a file on the click of a link in the Grid named as VIEW. The path I am binding to is the local path i.e., ~/Documents/ScanDoc/[FileName] but when i am opening it on the local server; I am getting the error as follows:-
File does not exist.
System.Web.HttpException: File does not exist. at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context) at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
But when I updated the PathColumn in database with this value:-"http://localhost:1383/~/Document/ScanDoc/[FileName]" which is actually being saved as "Documents/ScanDoc/[FileName]", the thing worked and i was able to see the file when i clicked on the link.
Now my problem is that how could i bind "http://localhost:1383/~" path to "Documents/ScanDoc/[FileName]" which is being saved in the database.
Thanks
Varun Sareen (Dot Net Developer)
|
|
|
|
|
Just grab the Url Authority like
String UrlAuthority = String.Format("http://{0}",Request.Url.Authority);
Now make a string of your static path
String Path = "Documents/ScanDoc/[FileName]";
Combine both for final Output
String FullPath = Path.Combine(UrlAuthority,Path);
And you're done.
|
|
|
|
|
Thanks Hiren, the thing you told worked
Varun Sareen (Dot Net Developer)
|
|
|
|
|
Glad it helped you.
You can always rate Answer if it helped you.
|
|
|
|
|
Following code does not handle columns that start with +. for example,
'+923339933886' is not rendered well(some kind of charmap characters shown).
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.
|
|
|
|
|
Are you sure you will get a better response this time then That[^]?
|
|
|
|
|
Check my answer here[^] for your question.
BTW please wait for the replies don't post duplicate questions. cheers.
|
|
|
|
|
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
|
|
|
|