How to access value of text box contained in juice tag control - juice-ui

I am building asp.net web form. in some of my pages i added juice tag control to organized collection data for Related use-cases.
For some reason unknown to me, when i switch my code from source view to design view, i can't see all the Text boxes. But when i view it in the browser i see the text box and the button. Because of this i cannot access value of my text box from code behind. Can some one tell me the cause of this and how i can get the values of my text box from code behind.
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div>
<juice:tabs id="_Default" runat="server">
<Juice:TabPage Title="Personaldata" ID="_Tab1">
<TabContent>
<label>FirstName</label>
<asp:TextBox ID="txtfirstname" runat="server"></asp:TextBox>
</TabContent>
</Juice:TabPage>
</div>
</asp:Content>
I try accessing my text box value as follows:
string firstname = txtfirstname.Text.Tostring();
But the text value is not recognized from code behind.

Related

How to set value in Ruby to text field with AutoPostBack on site in ASP

I have website written in ASP with searchTextBox with AutoPostBack and searchButton to search for value entered in searchTextBox.
Here is the code:
<asp:TextBox ID="searchTextBox" runat="server" AutoPostBack="True" Width="159px">enter value</asp:TextBox>
<asp:Button ID="searchButton" runat="server" Text="Search" Width="151px"
onclick="searchButton_Click" />
I would like to search for certain values using Ruby.
Here is my code:
search=#brows.text_field(:id=>'searchTextBox')
search.set(name)
#btnSearch=#brows.button(:id=>'searchButton')
#btnSearch.click
When I run script, value is entered, but before button is clicked it disapears.
How to stop this value disappearing?
When I do this manually value doesn't disappear. It is successfully send to next form.

Request.form doesn't return a value with Visual Studio 2013 in code behind

I think I'm getting blind....! What's wrong with the following code?
With Visual Studio 2013 "searchBox" doesn't return a value but with VS 2008 it works well.
CODE BEHIND
Partial Class _Default
Inherits Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Request.Form("searchBox"))
End Sub
End Class
HTML PAGE
<%# Page validateRequest="false" Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:TextBox ID="SearchBox" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" />
</asp:Content>
It can't works with VS2008 either. As it is a server control, the actual client id of the control won't be searchbox but a concatenation of all parents ids of the control. Something like ctl00_somePanel_someContainer_SearchBox.
Request.Form will contain raw html form control's values, including the value generated by the client side version of the SearchBox, with its actual generated id.
To solve your issue, you can:
read the SearchBox.Text property instead of reading the Form object (probably the best option)
replace the server control by a pure client one (<input type='textbox' id='SearchBox'/>
fix the control ID using CliendIDMode, but I believe this is a poor option
The easiest would be when you want to use Request.Form("searchBox") is to set it as follows:
<asp:TextBox ID="SearchBox" clientmode="Static" runat="server"></asp:TextBox>
This forces the object to be created with the name "SearchBox" that you set it too, not "ctl00_somePanel_someContainer_SearchBox" that is a name that only it knows how to interpret.
It is not the best way to access the object, but this will get you going the way you are doing it.

Page update after asyncfileupload completes upload

I see this question asked frequently and I have done extensive experimentation to try to get this to work. However everyone else's examples and answers have so far failed me. I am bemused. Here is the situation:
AsyncFileUpload is NOT in an UpdatePanel
Image and Label to be updated are in an UpdatePanel
Update should occur after the upload completes
The upload is indeed saving the file as expected. My problem is regarding getting the page to update after that happens. The file being uploaded is an image, and I would like that image to update. I am aware of some problems with images not updating on the client if you reuse filenames, but I am also printing it to a label just to be sure. I am certain the UpdatePanel I am targeting is not updating.
I have tried the following approaches:
Using the server side method to manually update a conditional UpdatePanel - this fails because the file upload is done in a frame. Sniffing the returned HTML shows that the correct HTML is actually sent back after the post, but of course to the wrong frame.
Using the client side method to trigger a javascript postback to my UpdatePanel. This does not work and I cannot tell why.
Using the client side method to trigger a javascript button click inside the UpdatePanel. Again, nothing happens and I don't know why.
Setting the UpdatePanel's trigger up so that it points directly at the AsyncFileUpload. No joy, but I knew that would be a long shot, keeping in mind the hidden frame.
Moving the AsyncFileUpload into the UpdatePanel and trying some variety of the above. When I do this, I lose all handle of the file being posted to the server and I cannot save the file in the first place.
Normally when I get this kind of error, where all the tutorials appear to be wrong, it turns out that my error is because I didn't set an ID on a control somewhere and it somehow mattered. I can't even see that in this case. Here is some code.
<fieldset class="pj_Pics">
<ul>
<li>
<label>Picture 1</label>
<asp:UpdatePanel ID="ajax_Pic1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Image ID="img_Pic1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<div style="position:relative;">
<div class="photoChooser">
<ajaxToolkit:AsyncFileUpload ID="fu_Pic1" runat="server" CssClass="pj_PicChoose" Width="84px" OnClientUploadComplete="picPost1" OnUploadedComplete="fu_PictureFile_UploadedComplete" ThrobberID="throb1" />
<span><asp:Literal runat="server" Text="click to change"></asp:Literal></span>
<asp:Image ID="throb1" runat="server" ImageUrl="~/images/throbber.gif" AlternateText="uploading image" />
</div>
</div>
</li>
</ul>
</fieldset>
protected void fu_PictureFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
bla bla bla;
// and update the image
img.ImageUrl = "~/" + webfolder + imageFileName;
thing.Text = img.ImageUrl;
}
function picPost1(sender, args) {
document.getElementById('<%# Button1.ClientID %>').click();
}
Any help greatly appreciated. There is obviously a ScriptManager on the page and the code I've shown is just the last thing I have attempted. Let me know if there is anything else you need to see.
Thank you!
I happen to face the same situation today, and this is how I solved it.
According to this LINK, there's no Postback is happening or even a ViewState since its Asynchronous FileUpload.
So in OnUploadedComplete I test file type and size before executing the SaveAs() in codebehind, then I test the same in OnClientUploadComplete to display messages and carry on the rest of the work like setting Images URL. Hope this helps.

RadWindow Modal Ajax Popup hide and show from code behind

I really need some help with this. I need to, using a RadWindow control, pop up a modal window containing a dynamically populated CheckBoxList based on user selection on dropdownlist changed. Please help with any sample or information to help me achieve this.
<telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Width="250" Height="536" VisibleOnPageLoad="false" Modal=true Behaviors="Minimize, Move, Resize,Maximize" Left="580" Top="-8" EnableShadow="true">
<ContentTemplate>
<div style="text-align: center;">
LIST OF STUFF TO DISPLAY
</div>
</ContentTemplate>
</telerik:RadWindow>
When using ContentTemplate, RadWindow behaves and can be used just like any other standard INamingConatiner.
For more details, check the help article and the demo on the subject.

View rendering problem

In my application I have two Master pages and they are used in various different cases. Say one master view just renders the top half of the page and another master view that renders the top half plus a navigation bar to the side. We pass around data to these Master pages using view models
Now in my controller my index action refers to the MasterPage with the navigation bar and a details tab that does not need the navigation bar. But there is a problem now whenever I try to render the Details page my site crashes at the Site.MasterWithNavigation although it is noway involved with my details view. i have no clue how it lands up there.
On attaching the debugger and checking where the pae is crashing it showed me it is crashing at the Site.MasterWithNavigation and on checking the call stack there was just one entry which took me to my other Site.Master and showed the exception at a random partial view rendering line. I thought just for the heck of it let me comment out that piece of line and again saw the crash occurring now at a different line where I render an HTML input element.
Any idea why the hell I am seeing this? Note we have other pages that use the second master page but for some reason they are all in a different controller called WhateeverDetailsController. Do you think there is a problem when we use two different master pages across two different actions within the same controller.
I am not sure why you are using multile master pages together but I use one master page only, and expose relevant tags to all pages such as:
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Title
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContentHolder" runat="server">
<%= Html.Script("jquery-1.4.4.min.js")%>
<%= Html.Script("jquery-ui-1.8.7.min.js")%>
<%= Html.Script("MicrosoftAjax.js")%>
<%= Html.Script("MicrosoftMvcAjax.js")%>
<%= Html.Script("MicrosoftMvcValidation.js")%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MenuContent" runat="server">
<% Html.RenderPartial("IManagerLinks"); %>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
<div id="leftContent50">
<h4>add a new comment</h4>
<% Html.RenderPartial("AddCommentUC", Model.AddComment); %>
</div>
<div id="rightContent50">
something else here
</div>
<br style="clear: both;" />
</asp:Content>
You could very easily do the same for the top part of your page, side part and title and use css to style everything up.

Resources