|
Hi,
I have a gridview that contains a list of name and i want to use a modalpopup to modify each row.
The problem came when i want to sort the column name inside the gridview i've added an updatePanel outside the gridview to make sure that only the gridview is reloading. due to that my ModalPopupExtender is not working.
the code excute but i m getting nothing inside the popup below the code :
<pre lang="HTML"> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" EnableViewState="false" AutoGenerateColumns="false"
DataKeyNames="Id" AllowSorting="True" OnSorting="OnSort">
<Columns>
<asp:TemplateField ItemStyle-Width="30px">
<ItemTemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="~/images/modifier.png" runat="server"
Width="10" Height="10" OnClick="imgbtn" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Name" DataField="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="pnlpopupName" runat="server" CssClass="modal" Style="display: none">
<div class="modal-inner-wrapper rounded-corners">
<table width="100%" style="height: 150px;" cellpadding="0" cellspacing="0">
<tr>
<td>
</td>
<td>
<asp:Label ID="ID" class="TDclass" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="TDclass">
Nom & Prénom
</td>
<td>
<asp:Label ID="lbNomPrenom" class="TDclass" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnOk" runat="server" Text="OK" OnClick="btn_ok" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</div>
</asp:Panel>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlpopupName" CancelControlID="btnCancel">
</asp:ModalPopupExtender>
and the code behind of the method that fill in the modalpopup :
<pre lang="c#">protected void imgbtn(object sender, ImageClickEventArgs e)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
string Key = GridView1.DataKeys[gvrow.RowIndex].Value.ToString();
lbNomPrenom.Text = Server.HtmlDecode(gvrow.Cells[1].Text);
this.ModalPopupExtender.Show();
}
|
|
|
|
|
papy-boom wrote: <asp:AsyncPostBackTrigger ControlID="GridView1" />
The way you have used triggers here is not complete. A control with multiple events(no fixed default event) fails to raise a trigger, so always defining control's event that will trigger UP is good. Try adding the event that will trigger the update panel.
Read about UpdatePanel triggers here:
MSDN: AsyncPostBackTrigger Class[^]
ASP.NET: Understanding ASP.NET AJAX UpdatePanel Triggers [^]
papy-boom wrote: i've added an updatePanel outside the gridview to make sure that only the gridview is reloading.
Why do you need to put grid outside update panel in order to just refresh a grid? You should do opposite. Just put grid in update panel?
|
|
|
|
|
Hi
I am searching for a job in web designing
I had a doubt will all the companies use dreamweaver for html, css, javascript or we have to use notepad.
Do anybody know about it.
I worked in Kuwait for a school they had dreamweaver
I was just wondering how is it here.
Thanks,
Mary
|
|
|
|
|
Mary Abraham wrote: I was just wondering how is it here.
What here? This is a global website.
Mary Abraham wrote: searching for a job in web designing
Not a right forum for job search. This is a site where people share their technical knowledge.
Mary Abraham wrote: ....Do anybody know about it.
It depends. Based on requirements, resource and various other factors decide the tools to build a web page. Using dreamweaver is not a thumb rule.
|
|
|
|
|
Mary, this site is devoted to Microsoft tools, especially Visual Studio. There are other tools available, of course, including Dreamweaver, but there are few people here who are familiar with products other than those offered by Microsoft. I use Dreamweaver and Visual Studio, but although both are excellent products, I'm not very skilled at using either. From my experience, if your primary focus is on building attractive, balanced sites with the minimum effort, Dreamweaver is probably your best choice. If your interest is primarily in building sites with a high degree of functionality and tight integration with backend systems, the Visual Studio course is a better choice. Microsoft provides tools which are extremely powerful and targeted at software developers, but their tools are rather weak in the design arena. Adobe caters to designers, not programmers, and provides tools which make an artist's life less stressful. A web designer can accomplish her goals using either toolset; both are quite capable of producing brilliant designs. But each has strengths and weaknesses. Only you can decide which fits your needs best.
Will Rogers never met me.
|
|
|
|
|
Generally, Roger, I would agree. However, Microsoft technologies are not the only game in town. PHP/MySQL is used across the internet, arguably, in greater numbers. And the tools you use won't cost you an arm and a leg like Microsoft and Adobe do. And if you are interested in blogging using such as WordPress, for example, and using a CMS such as Joomla, for example, would require PHP/MySQL. Besides, LAMP hosting is usually far cheaper than hosting using Microsoft technologies.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
No argument there, Richard. I only addressed the two systems that I've used; I'm not qualified to have an opinion on the others.
Will Rogers never met me.
|
|
|
|
|
I am new to WCF and I am trying to design wcf with SQL as backend.
So far I was able to:
1.Open solution and create my wcf service
2.in my IService.vb add following code:
Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web
<ServiceContract()> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class Service1
<OperationContract()> _
Public Shared Function SavePersonInfo(ByVal myPerson As Person) As String
Return "Hello, "
End Function
End Class
' Use a data contract as illustrated in the sample below to add composite types to service operations.
<DataContract()>
Public Class Person
<DataMember()>
Public Property MemberID() As String
<DataMember()>
Public Property GroupID() As String
End Class
3. Add <connectionstrings> to web.config
My question is?
Where would I call my DB connection/SQL function in order to save pass data?
|
|
|
|
|
Hi,
I've added a modal popup extender in my application as follow:
If ds.Tables(0).Rows.Count > 0 Then
ModalPopupExtender1.Show()
End If
If Checkbox1.Checked = True Then
loadgrid()
End if
However I've noticed that the modal pop up is loaded after checking the condition Checkbox1.Checked = True.
Any idea how to load the popup then check the condition Checkbox1.Checked = True
Cheers
|
|
|
|
|
I take it that you dataset is got inside you loadgrid() function, so of course you code would check that the dataset and then display the modal if it were empty. am I missing something here?
|
|
|
|
|
berba wrote: how to load the popup then check the condition Checkbox1.Checked = True
Just make sure that dataset's first table has some data to open modal popup independently.
All you need is to make this condition true without depending on checkbox state.
ds.Tables(0).Rows.Count > 0
|
|
|
|
|
Hello.
So I found this book in my parent's stash called "Using TCP/IP" by John Ray. It is a wonderful book in many ways, very descriptive, but it was published in 1999. IIRC, 13 years in technology is a very long time.
Does anyone know if this book is still relevant? Do we still use the 100mbit/s twisted-pair wiring scheme 100BASE-TX? Are the 10mbit thinnet wiring scheme 10BASE-2 still used?
Any(!) help regarding this and networking in general would be most appreciated, I find it very exciting.
Best regards
- Mossmyr
|
|
|
|
|
I am working on .NET 4.0 MVC project. I am trying to Ajax post a piece of data from my KO model. That data is a string in following XML format.
<SearchCriteria><Criteria SearchOn="Name" SearchValue="test 3" /></SearchCriteria>
I am trying to post it like this.
$.ajax({
url: destUrl,
data: ko.toJSON(DataToPost()),
type: "POST",
success: function (result) {
}
},
error: function (request, textStatus, errorThrown) {
alert(request.statusText);
}
});
Here you will notice the data being sent is "ko.toJSON(DataToPost())". DataToPost() returns the XML string contained in my KO model data member DataToPost. ko.toJSON() is used to convert the KO model data in JSON.
This throws a runtime exception which is normally thrown when we post anything containing javascript or html tags. This is a security feature by .NET. Following is the exception.
A potentially dangerous Request.Form value was detected from the client.
<SearchCriteria><Criteria SearchOn="...est 3\" /></SearchCriteria>
I faced similar situation sometimes back (though I was not using KO that time and it was normal post i.e. non Ajax). I overcame the problem that time by using javascript escape() but this time it failed. I used it as follows
$.ajax({
url: destUrl,
data: ko.toJSON(escape(SearchCriteria())),
type: "POST",
success: function (result) {
}
},
error: function (request, textStatus, errorThrown) {
alert(request.statusText);
}
});
Other popular fix is to disable this security either at page level or at application level. It could be done as follows.
Page level.
<%@ Page validateRequest="false" %>
Application level.
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
But doing away with this security is not good. I don't think it will be a wise move. Right now I don't know what to do. Need suggestions.
Thanks in advance!
|
|
|
|
|
I realized that it is difficult to serialize an XML formatted string hence instead of XML formatted string I decided to post List of Key value pair instead. This approach is working fine.
|
|
|
|
|
Hi
How can I navigate by one navigationbar image with different button home , aboat. contact in .NET ?
I have MasterPage and sitemap to navigate on my website.
muehai
tigrina lexikon ትግርኛ መዝገብ ቃላት seglelet.com
.NET and C# is the most interested thing to me.
I have Tigrina Lexikon which I work att http://www.seglelet.com company at the moment!
|
|
|
|
|
I have an XML and an XSL for it.
I want to know how can I display this data when I open an HTML page.
Is there any way I can include this xml in html, so that i can view this data?
I googled and also searched in The Code Project, i could only find the solutions using javascripts and asp. I also tried out with many samples which did not work out.
I want to use only XML, XSL and HTML to display the data.
Please help me. Thanks in advance.
|
|
|
|
|
|
I am using knockout (KO) in my MVC project. I create an MVC model (for a grid) on server and pass it to the view. On the view it is serialized and converted into a KO model (using ko.mapping) which in turn is used for binding. That binding is then used in HTML for grid creation.
This is how my MVC grid model looks like which in turn gets converted to corresponding KO model by ko.mapping:
public class GridModel
{
public GridBodyModel GridBodyModel { get; set; }
public GridContext GridContext { get; set; }
public GridHeaderModel GridHeader { get; set; }
}
public class GridBodyModel
{
public IList<GridRowModel> Rows { get; set; }
}
public class GridContext
{
public int TotalPages{ get; set; }
}
public class GridHeaderModel
{
public IList<GridHeaderCellModel> Cells { get; set; }
}
As it is clear the main model class GridModel is made of following classes which are present as properties:
GridBodyModel: Has list of rows to be rendered in the grid body.
GridContext: Has total number of pages as a property. It has other properties as well but that is out of scope of this discussion.
GridHeaderModel: Has a list of cells that has to be displayed in header of the grid.
Then I have this script that will execute on fresh page load.
$(document).ready(function () {
ko.applyBindings(Global_GridKOModel, document.getElementById("gridMainContainer"));
});
Global_GridKOModel = ko.mapping.fromJS (<%= DataFormatter.SerializeToJson(Model) %>);
Global_GridKOModel is global javascript variable.
Model is the MVC grid model coming from server.
A user can perform further search on the page again. I handle this by posting new search criteria via Ajax. On this post a new MVC model is created and is sent back as Ajax response. This new MVC Model is then simply used to update Global_GridKOModel using ko.mapping which in turn refreshes the grid (with new data) that was constructed earlier on fresh page load. This is how I am doing it.
$.ajax({
url: destUrl,
data: dataToSend
success: function (result) {
ko.mapping.fromJS(result, Global_GridKOModel);
},
error: function (request, textStatus, errorThrown) {
alert(request.statusText);
}
});
Everything is working fine except in the following scenario.
An Ajax request is made for which no result is returned i.e. GridBodyModel and GridHeaderModel is null in the model GridModel. That time grid rightly shows that no record has been found. This is correct. This happens by the following HTML binding.
<!--
<div data-bind="ifnot: GridContext.GridPager.TotalPages() > 0">
No record(s) were found.
</div>
<!--
<div data-bind="if: GridContext.TotalPages() > 0">
Grid construction happens here
</div>
Now after this if another Ajax request is made but this time records are returned (I have checked the response with firebug and it is confirmed that records are indeed returned). This time grid construction happens wherein various observable arrays are accessed. For example, to construct pager for the grid following is a piece of HTML binding I wrote.
<td data-bind="attr:{colspan: GridHeader.Cells().length }">
This time KO throws following error which can be seen in firebug.
Unable to parse bindings.
Message: TypeError: GridHeader.Cells is not a function;
Bindings value: attr:{colspan: GridHeader.Cells().length }
It work fine so long there are records being returned but it breaks after no record is returned as explained above. Please note GridHeader was null in earlier response when no records were returned. I smell something fishy in ko.mapping. I think there is some problem while mapping observable array.
So what is it that I am not doing right? Anyone please?
Please feel free to ask for clarification if I have not mentioned things clearly.
Thanks in advance.
|
|
|
|
|
I figured it out last night. Actually this was very basic mistake that I was making. I was trying to access an array after setting it to null. I will explain it how.
When result were returned that time GridHeaderModel and the IList Cells in it were defined i.e. were not null. That time ko.mapping was able to convert the model and create the model and arrary inside it. But when any ajax request were made wherein noo result was returned and GridHeaderModel was null, obviously the IList Cells was null too. That time ko.mapping did the same, the KO model that it updated, set GridHeaderModel to null too and the observable array Cells inside was no present which is as good as null. Now when I made another ajax request with some records returned, the ko.mapping tried to update the observable array Cells which did not exist (or was set to null) in KO model on the client, it failed. If instead of ajax it were fresh page load everything would have worked. So the solution is not to return any enumeration (those that will get converted to observable array) uninitialized to the client for KO model update. Hence when no record was to be returned I made sure that GridHeaderModel is not null and also made sure that the IList Cells is initialized though it did not contained any element. This fixed the problem.
This problem could be explaied with following example.
public class Demo
{
public IList<string> DemoArray;
}
public class DemoUser
{
public void UseDemo()
{
var demoInstance = new Demo();
demoInstance.DemoArray.Add("First Element");
}
}
Here in the UseDemo() method we have initialized the class instance Demo but the IList DemoArray remains un-initialized. So when we try to access it runtime exception will be thrown. This is what was happening in my case. In first ajax response I was setting the observable array to null i.e. un-initializing it and then in next ajax response I was trying to access it.
modified 19-May-12 2:26am.
|
|
|
|
|
I have the excel file (Insert.xls) and i want to bind the data from it.
I wanna bind data with various Textboxes for each excel column.
How can i read it ?
please suggest me or please pay the sample codes for it.
|
|
|
|
|
Hey they are 2 ways which you can achieve this. You can get the cell range and store it in an array and then read the values from the array like so :
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
for (int i = 1; i <= 10; i++)
{
Excel.Range range = worksheet.get_Range("A"+i.ToString(), "J" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
TextBox.Text = strArray[0].ToString();
}
}
or you could use OleDb like so assuming you have a sheet in the excel file called MyObject :
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=Excel 8.0");
OleDbDataAdapter da = new OleDbDataAdapter("select * from MyObject", con);
DataTable dt = new DataTable();
da.Fill(dt);
Hope this helps
|
|
|
|
|
Another way is to save the excel file in csv(tab seperated) format and use a streamreader to read the file. Then declare an array and split the reader into the array, if you need a code sample let me know and il gladly provide it.
|
|
|
|
|
Is there any specific harm or drawback if we use Session state in SharePoint 2010 ?
Actually we have a scenario in which we have to perceive the 100 rows (with seven column in each row) in a DataTable and perceive its values during the page refresh call that is being made on close of the SharePoint Modal Dialog box .
Actually we have to insert the rows to the datatable of parent page by opening a Modal Popup without submitting the data to the database .
Does storing the datatable with 100 rows in VIEWSTATE will be an alternate solution ,if Session state is not recommended ? Or we can go ahead with Session state ?
name :atharfaridi
from :pune university
currently residing in mumbai
|
|
|
|
|
I need to display a message box in my asp.net application with 3 buttons yes no cancel. I need to detect which button has been clicked and perform some actions depending on the button clicked.
I've tried the following code:
Dim result1 As Forms.DialogResult = System.Windows.Forms.MessageBox.Show("Message1", System.Windows.Forms.MessageBoxButtons.YesNoCancel, Forms.MessageBoxIcon.Warning, Forms.MessageBoxDefaultButton.Button1, Forms.MessageBoxOptions.DefaultDesktopOnly, False)
If result1 = Forms.DialogResult.Yes Then '(System.Windows.Forms.DialogResult.No)
//code
ElseIf result1 = Forms.DialogResult.No Then
//code
Else
Exit Sub
End If
it works only when the application is on my local machine.
When I tried to access the application from aserver, the message box is displayed on the server, not on the client browser.
Any help will be appreciated.
Cheers
|
|
|
|
|