|
Hi
I am using Gridview.In that I used text which is used as template field. I also use label in that template field. Now onchange event of each text box i want to visible my label. Onchange event I am passing text value for some checking. when I display using alert it showing that value. So How can I assign that value to label and show that label.
Because of label in template field I think its not working. I tried with test page without inserting label in itemtemplate gridview it showing exact result what i want that is showing text what I passed on to onchange event of textbox
So How can I Show the text using that label?
Thanks
sjs
|
|
|
|
|
You just need to have client ID of label.
First point, make the label's style.display='none' from server when you dont want ot display it.Pass the client id of the label on onchange event of each text box from server side itself.Now on onchange event you will be having the clientid of associated label just change the style as style.display='' .
Let me know if any query..Cheers!!
Brij
|
|
|
|
|
Hi,
If i passed labels clientid through on onChange event of Text then its not working.
my code is :-
<EditItemTemplate>
<asp:TextBox ID="txtEditPassword" runat="server" TextMode="Password" OnChange="Getlblvalue(this.value,<%=lblpwd.ClientID%>);" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtEditPassword" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEditPassword" Display="Dynamic" ErrorMessage="*"
ValidationExpression="([0-9,a-z,A-Z,*,@,$,-,+,?,^,_,&,=,!,%,(,),~,£,#,/,]){1,12}"></asp:RegularExpressionValidator>
<asp:Label ID="lblpwd" runat="server" ForeColor="Red" Visible ="true"></asp:Label>
</EditItemTemplate>
and my java script is:
<script language="javascript" type="text/javascript">
function Getlblvalue(str,lblid)
{
alert(lblid);
var gridViewCtlId = '<%=GVUserDataList.ClientID%>';
var grid = document.getElementById(gridViewCtlId);
var gridLength = grid.rows.length;
var sum = 0;
// //calculate sum of the prices looping through the gridview and operation in every cell
// grid.rows[5].cells[5].FindControl('lblpwd').textContent="Hello";
// sum = (grid.rows[5].cells[5].find.textContent);
// alert(grid.rows[5].cells[5].FindControl('lblpwd').textContent);
// //grid.rows[gridLength - 1].cells[5].innerHTML = sum;
}
</script>
Thanks
|
|
|
|
|
You have to attach the OnChange event to textbox at server side in grid's databound event.There you will get the client Id of label using find control.
First find the textbox and label in databound and attach the event like this at server side
txtEditPassword.Attributes.Add("onchange", "Getlblvalue(this.value('" + txtEditPassword.Text+ "','"+ lblpwd.ClientID+"');"); Cheers!!
Brij
|
|
|
|
|
ok Thanks for your help..I will try it..
Thanks Again..
|
|
|
|
|
your most welcome Cheers!!
Brij
|
|
|
|
|
hi
i worked on windows application and now i m working on web application for the first time.
the following is my code in defalut page
Partial Class _Default
Inherits System.Web.UI.Page
Dim i As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
i = i + 1
MsgBox(i.ToString())
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
i = i * 100
MsgBox(i.ToString())
End Sub
End Class
when i click button1 the value in i is 1.
but when i click button2,it is showing the value in i is 0
but ihave to get 100
can any one tell me whats happening at button2
|
|
|
|
|
First, format your code using the pre tags when posting. You've been around long enough to know this.
Understand that the web, and ASP.NET, is stateless. Each time a page is requested, or an action, such as a button click, causes a postback, all the variables you have declared are set to their default values unless otherwise persisted.
You will do well to pick up a book on ASP.NET and read it before proceeding. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
vijaylumar wrote: Dim i As Integer = 0
you declared i as 0 so you get result as 0
|
|
|
|
|
I need your help but have ideas but do not know how to implement them.
What I want is that the order of how the groups will eventually appear in the gridview are read from the database.
I have 1 to x groups.
In my GridView, the data are displayed with BoundField.
It looks like this.
<a href="http://img1.immage.de/0802377aunbenannt.jpg">http://img1.immage.de/0802377aunbenannt.jpg</a>[<a href="http://img1.immage.de/0802377aunbenannt.jpg" target="_blank" title="New Window">^</a>]
My question is how can sort each row?
|
|
|
|
|
Hi Muc! I am Not quite sure what are you looking for but maybe you need to program the sort event of gridview... something like
protected void GV_MyData_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, ASCENDING);
}
}
private void SortGridView(string sortExpression, string direction)
{
DataTable dt = GetDataTableSource()
DataView dv = new DataView(dt);
dv.Sort = sortExpression + direction;
GV_MyData.DataSource = dv;
GV_MyData.DataBind();
}
private const string ASCENDING = " ASC";
private const string DESCENDING = " DESC";
public SortDirection GridViewSortDirection
{
get
{
if (ViewState["sortDirection"] == null)
ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection)ViewState["sortDirection"];
}
set { ViewState["sortDirection"] = value; }
} ... it maybe helps a little! good luck!
|
|
|
|
|
Hi punkIsNotDead, what im askin myself is how i can sort my gridview depending on the rank column in the database?
Its Loos like this
http://img2.immage.de/09028ecclientpic.jpg[^]
When one of the arrows is clicked on, for example Asceding then then the line should high slip. Let's say we click the down arrow for AEC, then its value must be recalculated, which would be called that previous rank_value [2] jumps to 1 And the value of 1 was is then 2 Once everything is to be bound to the GridView.
http://img4.immage.de/09024bd3d3edbpic.jpg[^]
|
|
|
|
|
Hi punkIsNotDead, what im askin myself is how i can sort my gridview depending on the rank column in the database?
Its Loos like this
<a href="http://img2.immage.de/09028ecclientpic.jpg">http://img2.immage.de/09028ecclientpic.jpg</a>[<a href="http://img2.immage.de/09028ecclientpic.jpg" target="_blank" title="New Window">^</a>]
When one of the arrows is clicked on, for example Asceding then then the line should high slip. Let's say we click the down arrow for AEC, then its value must be recalculated, which would be called that previous rank_value [2] jumps to 1 And the value of 1 was is then 2 Once everything is to be bound to the GridView.
<a href="http://img4.immage.de/09024bd3d3edbpic.jpg"></a>
<a href="http://img4.immage.de/09024bd3d3edbpic.jpg">http://img4.immage.de/09024bd3d3edbpic.jpg</a>[<a href="http://img4.immage.de/09024bd3d3edbpic.jpg" target="_blank" title="New Window">^</a>]
|
|
|
|
|
When I browse to select a file using the FileUpload control, the file's full path is displayed in the accompanying textbox but when I try to get at the full path in my code, the path to the file is stripped off automatically and i can't find it. I need to perform different actions depending on what directory the file is from, so i need to get at the path. I seem to run into the same problem with the simple html file input control as well.
It seems like I must be overlooking something very simple. Does anyone know how I can get at the full path?
thanks so much,
Ashu
9818842034ashutosh kumar jha
|
|
|
|
|
I dont think this is actually needed, as the path that you would find from the fileupload control will not be the path to the server, rather it will be a path of the client.
If you still like to use it, all you can see is :
this.myfileUpload.PostedFile.FileName
Or find from
HttpContext.Current.Request.Files
or
<br />
Request.Form["fileuploadControl"]<br />
These are sent from the client. If this doesnt solves the issue, I think the browser is not sending the full path (depends on browser).
|
|
|
|
|
Dear sir,
basically i want to pass a complete local file path in a method which can be post a file in different server(means i want to upload a file on multiple server at a time, thats why i used ftp class in asp.net to upload the file, it is working Fine in Internet Explorer but not work with Mozila).
My Code Function is
public void uploadFileUsingFTP(string CompleteFTPPath, string CompleteLocalPath, string UName, string PWD)
{
//Create a FTP Request Object and Specfiy a Complete Path
FtpWebRequest reqObj = (FtpWebRequest)WebRequest.Create(CompleteFTPPath);
//Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
//If you want to access Resourse Protected You need to give User Name and PWD
reqObj.Credentials = new NetworkCredential(UName, PWD);
//FileStream object read file from Local Drive
FileStream streamObj = File.OpenRead(CompleteLocalPath);
//Store File in Buffer
byte[] buffer = new byte[streamObj.Length + 1];
//Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length);
//Close FileStream Object Set its Value to nothing
streamObj.Close();
//Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
}ashutosh kumar jha
|
|
|
|
|
Hey Asutosh,
I think you are missing out the point. From the web site, you can send files only through httpstreams. To invoke FTP from the client side you need client side sandbox apps etc which are capable of invoking Ftp requests to the server.
Other than that, if you are willing to invoke FTP request to the FTP server from the hosting application, you need to upload the files through HTTP, and then you need to send the file to the FTP location, invoking a new FTP session to that server.
Actually one thing you must remember, Server cant request a client to get a file. Even though you send the client full file path to the ftp server, if the client remains idle, server cannot get the file.
I hope this is clear now.
|
|
|
|
|
Hi,
I have a custom paged grid user control on my page. the problem is everytime the last page number is clicked it come out fine but if it is clicked again all the rows of the gridview are displayed irrespective of data and they disappear again when clicked and then reappear if next is pressed .
|
|
|
|
|
Look at this and compare
Paging without a wizard (SqldataSource control) [^]Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
you have to post some sample code also, to clarify this problem.
|
|
|
|
|
protected override void InitializePager(GridViewRow row, int columnSpan, PagedDataSource pagedDataSource)
{
try
{
if (PagerType == ThisPagerType.Regular)
{
try
{
if (CustomPaging)
{
pagedDataSource.AllowCustomPaging = true;
pagedDataSource.VirtualCount = VirtualItemCount;
pagedDataSource.CurrentPageIndex = CurrentPageIndex;
}
base.InitializePager(row, columnSpan, pagedDataSource);
}
catch (Exception ex)
{
throw ex;
}
}
else
{
pagedDataSource.AllowCustomPaging = true;
pagedDataSource.VirtualCount = VirtualItemCount;
pagedDataSource.CurrentPageIndex = CurrentPageIndex;
PlaceHolder plc = new PlaceHolder();
TableCell cell_0 = new TableCell();
TableCell cell_1;
{
cell_1 = new TableCell();
LinkButton prev = new LinkButton();
prev.Text = "<< Previous ";
prev.CommandArgument = string.Format("{0}", (pagedDataSource.CurrentPageIndex - 1));
prev.Visible = (pagedDataSource.CurrentPageIndex > 0);
prev.CssClass = "pagnPrev";
prev.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(prev);
for (int i = 0; i < pagedDataSource.PageCount; i++)
{
LinkButton numb = new LinkButton();
numb.ID = i.ToString();
numb.Text = Convert.ToString(i + 1);
numb.CommandArgument = string.Format("{0}", Convert.ToString(i));
if (i == pagedDataSource.CurrentPageIndex)
{
numb.Enabled = false;
numb.CssClass = "pagnCur";
}
else
{
numb.Enabled = true;
numb.CssClass = "pagnLink";
}
numb.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(numb);
if (i < pagedDataSource.PageCount)
{
Literal ltl = new Literal();
ltl.Text = " ";
cell_1.Controls.Add(ltl);
}
}
LinkButton next = new LinkButton();
next.Text = "Next >>";
next.CommandArgument = string.Format("{0}", (pagedDataSource.CurrentPageIndex + 1));
next.Visible = (pagedDataSource.CurrentPageIndex < (pagedDataSource.PageCount - 1));
next.CssClass = "pagnNext";
next.Click += new EventHandler(navigate_Click);
cell_1.Controls.Add(next);
}
// create a Table that will replace entirely our GridView's Pager section
Table tbl = new Table();
tbl.BorderWidth = 0;
tbl.Width = Unit.Percentage(100);
tbl.Rows.Add(new TableRow());
tbl.Rows[0].Cells.Add(cell_1);
tbl.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Right;
row.Controls.AddAt(0, new TableCell());
row.Cells[0].ColumnSpan = Columns.Count;
row.Cells[0].Controls.AddAt(0, tbl);
if ((FooterText != null) && (FooterURL != null))
{
Literal ltlLink = new Literal();
ltlLink.Text = @"<a href="""+ FooterURL +@""" title="""+ FooterText+ @""" target=""_self"">" + FooterText + "</a>";
this.FooterRow.Cells[0].Controls.Add(ltlLink);
}
else if (FooterText != null)
this.FooterRow.Cells[0].Text = FooterText;
}
}
public virtual void LoadGrid(MailSearch mailSearch, userAccount ,int pageCount)
{
try
{
mailSearch.PageSize = 20;
mailSearch.SelectedPage = pageCount;
MailResults mailResults = new MailResults();
//sent messages
if (ViewState["ReceivedFlag"] == null)
{
mailSearch.FromPartyId = userAccount.PartyId;
mailResults = userAccount .MailSearch(mailSearch, Helper.GetLoggedInIdentity());
}
//received messages
else if (ViewState["ReceivedFlag"].ToString() == "true")
{
mailResults = userAccount.MailSearchByReceivedMessages(mailSearch, userAccount.PartyId, Helper.GetLoggedInIdentity());
}
//sent messages
else if (ViewState["ReceivedFlag"].ToString() == "false")
{
mailSearch.FromPartyId = userAccount.PartyId;
mailResults = userAccount.MailSearch(mailSearch, Helper.GetLoggedInIdentity());
}
if (mailResults.MailCollection.Count == 0)
{ lblXYZ.Text = "Currently, You don't have ....."; }
else
{
int size;
if ((mailResults.RowCount) < (pageCount * 20))
{ size = (int)mailResults.RowCount; }
else { size = (pageCount * 20); }
lblXYZ.Text = "Mail ( " + ((pageCount * 20) - 19) + "-" + size + " of " + mailResults.RowCount + ")";
}
DataTable dt = new DataTable();
dt.Columns.Add("MailID");
dt.Columns.Add("FromUserName");
dt.Columns.Add("Subject");
dt.Columns.Add("CreatedDate");
dt.Columns.Add("LastViewedDate");
dt.Columns.Add("dteCreatedDate");
dt.Columns.Add("dteLastViewedDate");
DataRow drow;
foreach (Mail mail in mailResults.MailCollection)
{
drow = dt.NewRow();
drow["MailID"] = mail.MailId;
drow["FromUserName"] = mail.FromUserName;
drow["Subject"] = mail.Subject;
drow["CreatedDate"] = mail.CreatedDate.ToString("dd/MM/yyyy HH:mm");
if (!String.IsNullOrEmpty(mail.LastViewedDate.ToString()))
drow["LastViewedDate"] = mail.LastViewedDate.Value.ToString("dd/MM/yyyy HH:mm");
else
drow["LastViewedDate"] = mail.LastViewedDate;
drow["dteCreatedDate"] = mail.CreatedDate;
drow["dteLastViewedDate"] = mail.LastViewedDate;
dt.Rows.Add(drow);
}
this.gvMail.PageSize = mailSearch.PageSize.Value;
this.gvMail.VirtualItemCount = mailResults.RowCount.Value;
this.gvMail.CurrentPageIndex = pageCount - 1;
gvMail.DataSource = dt;
gvMail.DataBind();
}
catch (Exception ex)
{
xyz
throw;
}
}
|
|
|
|
|
Hi all,
I have a problem in my site that, when i call the java script in on load, it jsut going on loop. my code here
<script type="text/javascript">
function coolAl() {
alert("The page is loading... now!");
document.getElementById("PageRun").click();
}
</script>
<body onLoad="coolAl()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
where PageRun is an asp button which has some events on the aspx.cs page
even the events code is empty am getting looped.
it gets stopped when i remove
document.getElementById("PageRun").click();
what may be the reason. help me pleaser
|
|
|
|
|
An ASP.NET button causes a postback which reloads the page. You tell me why you're in a loop. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi, I'm having a strange problem when I'm testing my custom web control. The problem is when I have entered a value in the textbox and pressed next on to another screen. If I then go back (history.back) then the textbox is blank rather than showing the value entered.
This only seems to happen in Firefox and Chrome though and it is fine in IE. The value is being saved to the database ok. My class in inheriting from WebControl.
public class AutoCompleteTextBox : WebControl
If it helps, there is a lot of JavaScript used.
Does anybody have any idea how I can solve this please?
Thanksmodified on Monday, February 8, 2010 11:03 AM
|
|
|
|
|
Hello.
I wanna make a webpage to find ID or password.
If someone lost his password, the page should let him know his password by email.
so, I should make a function to send an email to be able to check out the password or new password.
Is there any good sample source??
please let me know how to make it..
Thank you.
|
|
|
|
|