|
I have tried combinations of the following to cancel the postback of a ButtonField. I am obtaining the data to view via Ajax and do not want the postback. Any ideas?
Code Behind in the dgData.RowDataBound event:
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onclick", "javascript:return viewRow(" & CType(e.Row.DataItem, BusinessObjects.Course).CourseID.ToString & ",this);")
End If Or without the "return"
e.Row.Attributes.Add("onclick", "javascript:viewRow(" & CType(e.Row.DataItem, BusinessObjects.Course).CourseID.ToString & ",this);") HTML:
<asp:ButtonField Visible="true" ImageUrl="../images/ViewSearch.gif" ButtonType="Image" Text="View Record" >
<ItemStyle HorizontalAlign="Center" Width="20px" />
</asp:ButtonField> JavaScript
function viewRow(id, row) {
try {
if (!(previousRow==null)) previousRow.backcolor= row.backcolor;
previousRow = row;
row.style.background="lightblue";
document.getElementById("<%=tblEdit.ClientID %>").style.display="none";
document.getElementById("<%=tblView.ClientID %>").style.display="inline";
requestSimpleService = CourseList.GetCourse(id, populateCourse, onError);
return true;
} catch (e) { alert(e.message);
}
} Note I am using the "<%=tblView.ClientID %>" due to using masterpages.
Thanks,
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
|
|
|
|
|
Hi Michael,
You need to add the onlick attribute to the ImageButton (the ButtonField with the ButtonType="Image" ) instead of the the row (tr) element. So there are two ways here to cancel the postback of the ButtonField:
+ Get reference to the ImageButton which is automatically added to the cell:
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton btn = e.Row.Cells[cellIndex].Controls[0] as ImageButton;
if(btn != null)
btn.On_Client_Click = "clientsidefunction(); return false;";
} + Use the TemplateField with the ImageButton in the ItemTemplate instead of the ButtonField:
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton On_Client_Click="clientsidefunction(); return false;" ... />
</ItemTemplate>
</asp:TemplateField>
|
|
|
|
|
Like this: (replace the X in cells(X) with the correct column number for you case)
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim c As Button = e.Item.Cells(X).Controls(0)
c.Attributes.Add("onclick", "return confirm('Do you really want to click this?')")
End If
End Sub
cheers
P
|
|
|
|
|
I m using a Pivot table and a chart in my asp.net 2.0(C#) application. I want to edit data in Pivot table and save in the sql database.
Is there any way of doing it?
|
|
|
|
|
What data do you want to save? Surely the data displayed in a pivot table is aggregated...
If you change the underlying data, I'm sure you can save it, but the answer to your question depends very much on how you are supplying the data to your pivot table - it's really just a matter of creating an update sql statement for anything that changes...
|
|
|
|
|
I saw one example of how to display Pivot Table
protected PivotTableClass pt;
pt = new PivotTableClass();
pt.ConnectionString ="Provider=SQLOLEDB.1;Data Source=AHD-2003;database=northwind;user id=sa;password=;";
pt.DataMember ="select * from suppliers";
pt.ShowDetails();
I m using OWC10. But there is no method named ShowDetails(). How can it be?
Do u have any example of how to display Pivot table programmatically.
|
|
|
|
|
I am developing a site in which I need to show images as thumbnails and on bringing mouse over them I want to show them as big like the images shown in below link
http://www.pensacolamls.com/(0v3xqr45qcmocsnrmh3nhmyo)/propertyDetails.aspx?mls=301025
Please tell me how can i make my .jpg files as thumbnails and on bringing mouse over them to show details as in above site.
Thanks,
Sandy
|
|
|
|
|
If you have 2 images (a thumbnail and a large image) you can just put the thumbnails on the page and render the inline popups on mouseovers (i suggest doing this with javascript cause otherwise you'll have troubles with postbacks).
If you do not have 2 images you will have to render your own thumbnails (on pageload for example) with System.Drawing libary. Then you can save your thumbnails just like you should have 2 images.
For an inline popup you can put a div with style "display:none" wherin you put your image. And onmouseover (from your thumbnail) you change the style of the div to display:div. With css you can place the div where you want on the screen.
|
|
|
|
|
I have a asp.net 2.0 web application that needs to open a word template from server, user change something, and then save back to server. Is it possible? Any help is appreciated.
|
|
|
|
|
It is possible using Office Interop, but before you do I'd suggest you look at what Microsof themselves have to say on the subject:
1) licensing: Microsoft require Office licenses for any server wanting to do this:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q243006#kb2[^]
2) (more importantly) there are technical limitations to running this kind of thing on the web:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^]
If you scroll down to where it says "Problems using Automation of Office server-side" in para 2 it says (in bold!):
"This fact alone makes running Office Applications from a server-side environment risky and unsupported."
So all in all, not a good idea....
There are 3-rd party components you can buy which will do the job - do a Google search.
cheers
Phil
|
|
|
|
|
Thanks for the reply.
What I understand is that if using Office Interop Office needs to be installed on web server. Even so it still can not save changed word document back to server.
Do you have any suggestion for the 3rd party component.
|
|
|
|
|
|
I have this in my html
<asp:DataList runat="server" ID="dlEntry" >
<ItemTemplate>
<AddOn:PostItem runat="server" UserRegisterDate="8/9/1972" UserTitle="Testing" TotalPosts="15" UserLoginName="NickTurner"/>
</ItemTemplate>
</asp:DataList>
my class file looks like so:
private DateTime _dtUserRegisteredDate = DateTime.Now;
private string _sTitle = "";
private int _iTotalPosts = 0;
private string _sUserName = "";
protected void Page_Load(object sender, EventArgs e)
{
}
public DateTime UserRegistedDate
{
get { return _dtUserRegisteredDate; }
set { _dtUserRegisteredDate = value; }
}
public string UserTitle
{
get { return _sTitle; }
set { _sTitle = value; }
}
public int TotalPosts
{
get { return _iTotalPosts; }
set { _iTotalPosts = value; }
}
public string UserLoginName
{
get { return _sUserName; }
set { _sUserName = value; }
}
In the WUC control is looks like
<asp:Label ID="Label1" runat="server" CssClass="PostNormal" Text='<%=UserLoginName%>'></asp:Label>
The value is being set. I saw this from stepping through the code. But when it prints on the browser its blank. All of the properties.
This is VS2005
What am I forgetting?
Thanks
1 line of code equals many bugs. So don't write any!!
-- modified at 9:21 Thursday 27th April, 2006
|
|
|
|
|
Hi Nick,
You cannot use the inline render code expression <%= ...%> to assign a value to the property of a server control. In this case, you either set the property in code or use the data binding expression:
<asp:Label ID="Label1" runat="server" CssClass="PostNormal" Text='<%# UserLoginName%>'/> And in the Page_Load you call the DataBind method of the label to bind the value UserLoginName to the Text property.
|
|
|
|
|
actually the problem was this
and yeah the equals was wrong
But if I have inline, I can not include text i.e...
Text='<%# UserLoginName%>' will work
but
Text='LoginName: <%# UserLoginName%>'
will not.
if I take out "LoginName:" and move that too another label it works. very odd
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
The sample code simply looks like this:
Text='<%# "LoginName: " + UserLoginName %>'
|
|
|
|
|
LOL.
I didn't think of that.
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Right I have a flash interface, and I need to pass a variable from flash to asp.net in order to set a variable that is important to the running of my web page.
here is my action script
******************************************
btn_1.onRelease = function(){
PosId = "First";
getURL("WebForm2.aspx", "_self", "POST");
};
******************************************
Now I need to know how to retieve that vaiable in asp.net.
I have tried using,
Dim Pos As String
Pos = Request.QueryString("PosId")
But this doesn't work, any help would be appreciated.
|
|
|
|
|
Well you specify the POST protocol in the GetURL, so it would be
Request.Form["PosId"]
or specify GET in the getURL line and your code should work.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I am facing a big problem in using datagrid.. while designing datagrid i dont know no of columns and no of rows.. So I am creating datacolums on the basis of a the resultset returned by the query at runtme. My problem is I am populating resultset into DATA Table then binding it to datagrid, Now I want the last column to be of type Combo Box, which is extra column and is not returned by the query.
Kindly let me know whther i can create addtional column in such a way at runtime
|
|
|
|
|
Basically, you can dynamically create the last column containing the DropDownList/ListBox control, then add it to the Columns collection of the datagrid control. To create the custom column, you have two options:
+ You can create a custom template column which implements the ITemplate interface, you can see more info from the article[^]. The downside of this way is that you cannot handle the postback event of the dropdownlis/listbox control if you want to do that.
+ Another option is that your custom control can inherit from the DataGridColumn class, and override the InitializeCell method to add the dropdownlist/listbox control to the table cell.
|
|
|
|
|
when i try to upload the file it gives error "Access denied".
then it gives me solution to change the rights of folder going into the security tab.
when i goto the property of project it shows me only four tab.....
General -- Sharing --WebSharing---Customize.
no security Tab.
what should i do to resolve this Error.
|
|
|
|
|
The error is suggesting that your ASP.NET application does not have priveledges to write to the upload folder - you indicate that you were looking at the "property of project" - did you mean the properties of the upload folder?
What operating system are you running? Are you using NTFS for the file system?
|
|
|
|
|
|
Vasudevan Deepak Kumar wrote: For your problem, you can open inetmgr. Navigate to the virtual directory, RightClick properties and give 'Write' Access from there. That alone should work.
Ouch. You just gave the entire world write permission to the folder.
If the file system is not NTFS, it is not a permission problem. A FAT disk has no permission system at all.
---
b { font-weight: normal; }
|
|
|
|