|
The process is Master page is loaded first then its content page is rendered. until the whole page is loaded, you cant call anything from content page.
I would suggest to use javascript onload event of body to do this.
|
|
|
|
|
|
I want to edit template in gridview. how can I place an icon in a template, and then how to use it.
The problem with me is that i am placing gif or png image file, which does not show any property. so how can i make my own icon from these images.
|
|
|
|
|
I dont get your problem. You might easily show an Image control inside EditTemplate of the gridview to show an image...
|
|
|
|
|
What is your actual problem or Business requirement ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
you can use an image control. lets say you are Displaying a username you can bind a Username to a Label and bind the icon to a image control. like this
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" /> <br />
<asp:Label ID="myLabel" runat="server" Text= '<%# Eval("Title")%>'/>
<asp:Image ID="myicon" runat="server" ImageUrl="~/icon.gif" />
</ItemTemplate>
hope this Helps
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/
|
|
|
|
|
Hi all,
I want to create a windows component in such a way that when i use it in any windows application,in run time i want to display the properties of the component created so that if i change the value of any property it should effect the component.
How can i do it ?
i am using VS 2008.And want to implement it using c#.Is there any type of template to be used.
Thanks in advance....
|
|
|
|
|
Ha ha ..
Just bind your component using PropertyGrid. Its a great control for windows env, which changes properties at runtime at ease.
Just see the manual on its usage, make a class and expose all the properties through that control, so that whenever the property is changed, it should affect the visual.
But does it belongs to ASP.NET? You should have posted this in C# section rather.
|
|
|
|
|
Hi ,
What is the difference between website and web application ?
Thanks in advance
Azeez.
|
|
|
|
|
The main difference of Website and Web application is :
Websites generally deploy source codes in the server if you publish it. Thus VStudio will not compile the total code to produce dll, rather it will place the files in the server with source code. Any change can be easily made in the production server without redeploying the entire project.
Web applications on the other hand produces an assembly for all the pages and deploys it to the server.
|
|
|
|
|
There are more differences.
In one case, a friend of many was working with MasterPages and Master-MasterPages.
In Web Application, FormC can access FormB, FormA and so on easily. You can't do the same in Web Sites. Web Sites have the advantage only of being able to be loaded "partially" (as each form can be loaded independently).
|
|
|
|
|
I have a vb.net (WebForm) program that is for initial data entry and if the transaction needs to be corrected it doubles as Edit/Update. I have a series of DropDownLists that work perfect when in initial entry mode.
The problem comes when re-populating the transaction and appropiate dropdownlists are being populated in the code-behind.
The problem is that the dropdownlists need to be populated with all employees and then the specific employee that is to appear (normally selected, now force selected in code-behind) does not fire the SelectedIndexChanged Event a second time without a page level update.
Normally just changing the SelectedValue will cause the correct employee to appear. But, all of the elements of the dropdownlist have just been set, so the system does not recognize the new selection as one that is to be displayed.
With SelectedIndexChanged being a "Server Side" Event is there a way to force this event from the clientside in code-behind? Or maybe there is a way to reset the selectedindexchanged property to think is has not been changed yet?
If so, could you be kind enough to supply an example?
|
|
|
|
|
I think you shouldnt rely on serverside events. Rather call the method to repopulate the control yourself.
|
|
|
|
|
I agree with you on that.
Please follow the logic here and make a suggestion with code sample if appropiate.
This is a bound dropdownlist..
DataFieldText = EmployeeName
DataFieldValue = EmployeeID
So I Deliver all of the employees to the DropDownList first and that works. All Employees are in the dropdownlist just fine. On the update path in the program, before the first display of the page, I set SelectedValue = EmployeeID, for the employee to be edited. This should cause that employee info to be displayed when the page is presented for the first time and it is not...
Any ideas on why?
Thanks in advance for your assistance..
Chuck...
|
|
|
|
|
Problem resolved..
Appears to have been a combination of programmer error and Data corrupted by the infamous Trailing SPACE. Thanks for your input. Made me go back and go line by line and letter by letter...
|
|
|
|
|
Wow.. Thats great to hear that.
|
|
|
|
|
HI guys i am working with listview conrol and objectdatasource
there is an udate metod wo which my dataobject is bound
bit it does not work, i put a break on updating event of the objectdatasource
but it doest not even break here , delete is working fine ,
update method and delete method taking the type of object.
here is my code
<EditItemTemplate>
<tr style ="background-color:Yellow">
<td class ="Controls">
<asp:LinkButton ID = "EditButton" runat ="server" Text ="Update" CommandName ="Edit"></asp:LinkButton>
<asp:LinkButton ID = "DeleteButton" runat ="server" Text ="Cancel" CommandName ="Cancel"></asp:LinkButton>
</td>
<td class ="Controls">
<asp:TextBox ID = "up_txtupdatecustomerid" runat ="server" Text = '<%#Bind("customerid")%>'></asp:TextBox>
</td>
<td>
<asp:Label ID = "uo_orderid" Text = '<%# Bind("Orderid") %>' runat ="server"> </asp:Label>
</td>
<td>
<asp:TextBox ID ="up_txtshipaddress" runat ="server" Text ='<%#Bind("shipaddress") %>'></asp:TextBox>
</td>
<td>
<asp:TextBox ID ="up_txtshipcity" runat ="server" Text ='<%#Bind("shipcity") %>'></asp:TextBox>
</td>
<td>
<asp:TextBox ID ="up_txtshipcountry" runat ="server" Text ='<%#Bind("shipcountry") %>'></asp:TextBox>
</td>
</tr>
</EditItemTemplate>
Tauseef A Khan
MCP Dotnet framework 2.0.
|
|
|
|
|
|
Hey....
I am very sorry, I didnt saw your last replies. First of all, it seems that your GridView is inside an updatepanel. If this is the case it cant be rendered. It will throw an error like Control 'Grid' of type 'GridView'must be placed inside a form tag with runat=server.
Actually RenderControl looks for Form Element when it Renders. So if you place it as a ContentItem of UpdatePanel , it will not take it as a direct element of HtmlForm. Hence it cant execute RenderControl of the control. So, here is the solution :
//Place this in your code behind to remove the controls. This might be a general function which can be used for any types.
private void ClearElements(Control ctrl)
{
for (int i = ctrl.Controls.Count - 1; i >= 0; i--)
{
ClearElements(ctrl.Controls[i]);
}
if (!(ctrl is TableCell))
{
if (ctrl.GetType().GetProperty("SelectedItem") != null)
{
LiteralControl literal = new LiteralControl();
ctrl.Parent.Controls.Add(literal);
try
{
literal.Text =ctrl.GetType().GetProperty("SelectedItem").GetValue(ctrl, null) as string;
}
catch
{}
ctrl.Parent.Controls.Remove(ctrl);
}
else if (ctrl.GetType().GetProperty("Text") != null)
{
LiteralControl literal = new LiteralControl();
ctrl.Parent.Controls.Add(literal);
literal.Text = ctrl.GetType().GetProperty("Text").GetValue(ctrl, null) as string;
ctrl.Parent.Controls.Remove(ctrl);
}
}
return;
}
//Replace the code snippet in your code just where you wrote :
StringBuilder sb = new StringBuilder();
StringWriter strw = new StringWriter(sb);
HtmlTextWriter htmlw = new HtmlTextWriter(strw);
ClearElements(dgSiparisler);
HtmlForm form = new HtmlForm();
Controls.Add(form);
form.Controls.Add(dgSiparisler);
form.RenderControl(htmlw);
snd.sendconMail("cinersan@hotmail.com", sb.ToString(), "Üyelik Bilgileri");
I think this will solve your issue.
|
|
|
|
|
Dear Abhishek,
you are really a good guy with a lot of patience...
I did not write earlier since I wanted to check the code first. As you said, I suspected from the update panels, and I have already removed it. Therefore I assume I do not need clear element. I checked in both ways anyway.
The thing is, when I render gridview by adding form, program gives, a page can only have one form tag. When I try to render it alone I receive should be within form tag.
I really do not understand.
Thanks alot.
|
|
|
|
|
Yes, But I have used this at least thousand times. It works.
Are you using a simple gridview or any 3rd party gridviews?
I dont know why you are getting this error
|
|
|
|
|
I do not understand either, I send you may aspx page there are no 3rd party element. Could it be caused by a service pack or something like that? Am I supposed to load anything for VS08?
I had a code for exporting data to excel in (VS03) where I did also render a gridview. It does not work either.
It is deadlock..
|
|
|
|
|
Yes.. I think there must be something wrong with the code. It must be working.
If there is no UpdatePanel then only RenderControl does all.
Create a new page, place a gridview with only few elements. And then try to use the same code. See if it exports in your server. If it does, increase the design a bit and gradually move towards the code you made and find out where exactly the problem is.
|
|
|
|
|
Dear Abhishek,
Here are the test you asked for... Completely different project the same result. I know I am asking alor but, could it be possible for you to test it.
Aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="dgSiparisler" runat="server">
<Columns>
<asp:TemplateField HeaderText="Adet" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblAdet" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "DataAdi")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
cs page:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Text;
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.IO;
namespace Test
{
public partial class _Default : System.Web.UI.Page
{
Class1 u = new Class1();
protected void Page_Load(object sender, EventArgs e)
{
dgSiparisler.DataSource = u.tbl_Al();
dgSiparisler.DataMember = u.tbl_Al().TableName;
dgSiparisler.DataBind();
StringBuilder sb = new StringBuilder();
StringWriter strw = new StringWriter(sb);
HtmlTextWriter htmlw = new HtmlTextWriter(strw);
//ClearElements(dgSiparisler);
HtmlForm form = new HtmlForm();
Controls.Add(form);
form.Controls.Add(dgSiparisler);
form.RenderControl(htmlw);
}
}
}
|
|
|
|
|
Ohh... I am sorry Ersan, as you are about to render the same page which is loading, the server will actually put the gridview inside the Form until it passes the Page_Load. Do this :
Place
<%@ Page ... EnableEventValidation = "false" %>
in the page directive of your page. Now place this in the code behind :
public override void VerifyRenderingInServerForm(Control control)
{
}
Overriding this function will automatically disable the checking of server side form element. And as I have also disabled Event Validation, so any event validation error generation while rendering the Gridview will also be suppressed.
So your server side code will look like :
StringBuilder sb = new StringBuilder();
StringWriter strw = new StringWriter(sb);
HtmlTextWriter htmlw = new HtmlTextWriter(strw);
this.dgSiparisler.RenderControl(htmlw);
string html = sb.ToString();
No need to create a new form element. Just do it, I am sure it will work.
|
|
|
|