|
Continues from this post[^] ~
How did you use the UpdatePanel? You should not put the whole body into the UpdatePanel.
Take a lot this link[^]
According this example, the label should be placed in UpdatePanel. If you have some more controls in that page, you shouldn't put all of them in UpdatePanel.
|
|
|
|
|
Member 4648491 wrote: Can any body say how can we ajaxify the exsiting ASP.Net Site
AJAX is just javascript. If you are talking about MS Ajax toolkit, you need to make lot of changes in web.config file. Easy way would be creating a new AJAX enabled website and copying the web.config entries to your current web.config.
|
|
|
|
|
Don't ask the same things over and over. The question made no sense when you first asked it, and it still doesn't. A timer is javascript, it doesn't need ajax. The page will not flicker if you use AJAX. Try sticking to one thread, and explaining yourself.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all
i have a link button to add records and a dropdown list filled with data from a stored procedure and i have added "All" with index 0 at the top of the DDL.
i need a validator to prevent entering insert page unless the user chooses a value from the DDL other than "All"
i have used the following validator but not working
<asp:DropDownList ID="ddlName" runat="server" AutoPostBack="True" Width="470px"><br />
</asp:DropDownList><br />
<asp:CompareValidator ID="nameVal" runat="server" ControlToValidate="ddlName"<br />
Display="Dynamic" ErrorMessage="Please chose a name." Operator="NotEqual" Type="Integer" ValueToCompare="0">*</asp:CompareValidator>
Any ideas!!!
|
|
|
|
|
samerh wrote: ValueToCompare="0">
What about changing 0 to "All"?
|
|
|
|
|
Didnt work too! Any other ideas.
I want the validation to alert me when i press the link button and iam choosing "All" that has index 0 from the DDL.
May be a java script will do it!!! Iam just wondering!!!
|
|
|
|
|
u should use the javascipt , there detect the dropdownlist id and find the current index , if the index is 0 then alert the user to select other then all.
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
I have tested. It works.. Can you try it again? Let's say there is one dropdownist and comparevalidator in your page. Set like that "ControlToValidate="DropDownList1"" and "ValueToCompare="All"" in CompareValidator.
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True">
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:dropdownlist>
<asp:comparevalidator id="CompareValidator1" runat="server" errormessage="CompareValidator">
ControlToValidate="DropDownList1" ValueToCompare="All"></asp:comparevalidator>
</div>
<asp:button id="Button1" runat="server" text="Button" />
</form>
</body>
</html>
Write the following code in Server-side. (Note that I used the arraylist in that sample. You can still use DDL instead of ArrayList.)
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
ArrayList al = new ArrayList();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
al.Add("All");
al.Add("Michael Sync");
al.Add("Nav");
al.Add("Dave");
al.Add("Toolbox");
DropDownList1.DataSource = al;
DropDownList1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
}
}
Run the webproject.. Select "Nav" and click "Button". then, you will get the error as the way it should be. And select "All" and click "button". there won't be any error. I hope this is what you want.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
Hi Everybody,
I am developing a weblproject in C# using .net2005.
In my page i have a Gridview, some text boxes, dropdown lists to enter data and a button to create a new row in the Grid.
The functionality is when user enters data in the textboxes and selects using dropdown and he has to click create button to create a new row in the Grid.
It is working fine when user clicks the create button once.
When user clicks the button multiple times (continously) then that no of data rows are creating in the gird. Here i need only one row in the Grid.
How can i overcome this problem.
Thanks in Advance
Ramu
|
|
|
|
|
After the insert line try to use
Response.Redirect(Request.Url.PathAndQuery)
HTH
|
|
|
|
|
Thanks for your response.
This is not working.
Here i am not directly inserting the record into the Grid. First i am writing that record to a CSV File.From that I am constructing a datatable and giving that datatable as a datasource to the Grid.
THis is the requirement of the project.
Ramu
|
|
|
|
|
Ramu.M wrote: When user clicks the button multiple times (continously)
You can prevent this by disabling the button.. If the users click the button, you can disable it by using Javascript. After the processing is done, you can re-enabled it.
|
|
|
|
|
|
I am using asp.net+vb.net
I want to export datas from sqlserver to excel.I wrote code for that.My it display in the internet explorer same page. I want to display in another page and want to set only print button for that page.
The code i wrote is given below.
*****************
Private Sub BindReport()
If Session("Rep") Is Nothing Then
Dim ConnInfo As New ConnectionInfo
With ConnInfo
.ServerName = "User1"
.DatabaseName = "IMS"
.UserID = "sa"
.Password = ""
End With
Dim rep As New ReportDocument
rep.Load(Server.MapPath("Crystalreport2.rpt"))
Me.CrystalReportViewer1.ReportSource = rep
Dim RepTbls As Tables = rep.Database.Tables
For Each RepTbl As Table In RepTbls
Dim RepTblLogonInfo As TableLogOnInfo = RepTbl.LogOnInfo
RepTblLogonInfo.ConnectionInfo = ConnInfo
RepTbl.ApplyLogOnInfo(RepTblLogonInfo)
Next
Session("Rep") = rep
End If
Me.CrystalReportViewer1.ReportSource = Session("Rep")
Me.CrystalReportViewer1.DataBind()
End Sub
**************************
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindReport()
Me.CrystalReportViewer1.ShowFirstPage()
End If
end sub
******************************
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
crReportDocument = New ReportDocument()
crReportDocument.Load(Server.MapPath("crystalreport2.rpt"))
Fname = "C:\exports\" & Session.SessionID.ToString & ".xls"
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
Dim oStream As New MemoryStream
oStream = crReportDocument.ExportToStream(ExportFormatType.Excel)
oStream = crReportDocument.ExportToStream(ExportFormatType.Excel)
report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.BinaryWrite(oStream.ToArray())
Response.End()
end sub
and also i want to display it in word how can i do the pls give code also.
|
|
|
|
|
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Clear()
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", "tmc.xls"))
'Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "kumaresh"))
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
'Response.ContentType = "application/ms-excel"
Response.ContentType = "application/"
Dim stringWrite As New StringWriter()
Dim htmlWrite As New HtmlTextWriter(stringWrite)
GridView1.RenderBeginTag(htmlWrite)
GridView1.RenderControl(htmlWrite)
GridView1.RenderEndTag(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
|
|
|
|
|
i am using crystal report in this code.My program working properly but i want to display only print button in toolbar not other toolbar buttons.
I also want to export this crystal report details in word.
How can i do this.Pls help
|
|
|
|
|
Is the data in a table with datatype image is editable in database.When i stored an image into db,and try to modify it an error occurs that the cell is not editable.Why this occur.
|
|
|
|
|
SreejithAchutan wrote: Is the data in a table with datatype image is editable in database.
Not editable. You can't edit it manually. You probably need to use the SQL statement..
|
|
|
|
|
I tried it using sql update command itself ,then also an exception of string or binary data truncated is occured.
|
|
|
|
|
Can you please show us the code for updating the image column? so, we can figure out what wrong in your code?
|
|
|
|
|
public void UpdateUnitDetails(int UnitId, string UnitName, string UnitShortName, string Location, string UnitLogoPath, string UnitStream, string MaxStudentsPerClass, string LastModifiedByUser)
{
string sqlstatement;
Boolean isUpdated;
try
{
sqlstatement = "UPDATE Units SET UnitName='" + UnitName + "',UnitShortName='" + UnitShortName + "',Location='" + Location + "',UnitLogoPath='" + UnitLogoPath + "',UnitStream='" + UnitStream + "',MaxStudentsPerClass='" + MaxStudentsPerClass + "',LastModifiedByUser='" + LastModifiedByUser + "' WHERE UnitId='" + UnitId + "'";
isUpdated = dbtObj.ExecuteSqlCmd(sqlstatement);
}
finally
{
}
}
protected void btnModify_Click(object sender, EventArgs e)
{
MembershipUser MU;
int UnitId;
string ID;
try
{
MU = Membership.GetUser();
string LastModifiedByUser = MU.UserName;
ID = Gdv_Unit_List.SelectedDataKey.Value.ToString();
UnitId = int.Parse(ID);
Gdv_Unit_List.Columns[0].Visible = true;
string logo = insunit.UploadUnitLogo(UnitId);
if (logo != "")
{
insunit.UpdateUnitDetails(UnitId, Txt_UnitName.Text, Txt_ShortName.Text, Txt_Location.Text, Upload_Logo.FileName.ToString(), DdlStreamList.SelectedItem.ToString(), TxtStdperClass.Text, LastModifiedByUser);
}
else
insunit.UpdateUnitDetails(UnitId, Txt_UnitName.Text, Txt_ShortName.Text, Txt_Location.Text, Upload_Logo.FileName.ToString(), DdlStreamList.SelectedItem.ToString(), TxtStdperClass.Text, LastModifiedByUser);
Gdv_Unit_List.Columns[0].Visible = false;
BindGrid();
}
finally
{
}
}
Thsi is the code .
|
|
|
|
|
SreejithAchutan wrote: public void UpdateUnitDetails(int UnitId, string UnitName, string UnitShortName, string Location, string UnitLogoPath, string UnitStream, string MaxStudentsPerClass, string LastModifiedByUser)
{
string sqlstatement;
Boolean isUpdated;
try
{
sqlstatement = "UPDATE Units SET UnitName='" + UnitName + "',UnitShortName='" + UnitShortName + "',Location='" + Location + "',UnitLogoPath='" + UnitLogoPath + "',UnitStream='" + UnitStream + "',MaxStudentsPerClass='" + MaxStudentsPerClass + "',LastModifiedByUser='" + LastModifiedByUser + "' WHERE UnitId='" + UnitId + "'";
isUpdated = dbtObj.ExecuteSqlCmd(sqlstatement);
}
finally
{
}
}
What is the code for updating the image? Are you updating the path of image (string) or image (bytes)?
The code below is for updating the image column ... (Note: I typed just like that so you may need to fix some syntax errors but you can get the idea from that code. )
<br />
byte[] img = <br />
SqlCommand update = new SqlCommand("UPDATE Person SET ImageColumn = @image<br />
WHERE personalID = " + pID, con);<br />
<br />
SqlParameter imageParameter = update.Parameters.Add("@image",<br />
SqlType.Image);<br />
imageParameter.Value = img;<br />
imageParameter.Size = img.Length;
Hope it helps..
|
|
|
|
|
OT: Your code for the sql statement is a sql injection attack waiting to happen. It's best not to use string concatenation, but rather use parameterized queries for safer coding. Read the SQL Injection Attack article on this site by Colin Mackay.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Actually we can modify obnly once .if we try to modify next time then an error had occured.What is the reason."The error is String or Binary is truncated".Is this is due to database design.lz help me
|
|
|
|
|
I cahnge the image into byte and save and also when modifying the image will be converted.But the pbm occurs only once we can modify the data.when we tried to modify next time an exception occurs.What is the pbm is the pbm in table design.plz help me.
|
|
|
|