Tag Archives: Wizard

[RESOLVED]Reference a project in your solution programmatically

Hi

I have projects that can be added to my framework MVC solution after the fact. What I want to do is after they were added, to be able to in the front end programmatically add there reference to my main project’s references.

There is the following link:

http://www.codeproject.com/Articles/11658/Programmatically-add-references-to-Visual-Studio-N

E.g. Solution MyModel, Project – Main Project, SubProject1, SubProject 2.

How do I add SubProject2 as reference to Main Project.

Like, when you right click in Main Project References, Add References and in Projects you get the project tab to choose your project.

Thanks

Hi,

Add reference almost the same with solution. There is a choice at the same time with "solution", choose "browse" and at the click "Browse" at bottom wizard, and point to "objdebug<SubProject2_name>.dll" or "objrelease<SubProject2_name>.dll".

Have fun

Hi

Sorry, not following? I need to do this in code behind without the user being aware. The user will create a new object called a project. Then this will create my project in the background, adding it to the solution and then it needs to add the reference
to the new project in my main project.

Hope this makes sense.

Thanks

Hi,

sunettew1

Like, when you right click in Main Project References, Add References and in Projects you get the project tab to choose your project.

Add References, and in Browse Tab below of project tab, there is also
Browse at the bottom of the wizard and click it to browse to the folder where SubProject2.dll located.

I thing that is what you need. Doe’s not it?

Have fun

Hi

To add it in code behind. The user shouldn’t browse  to where the dll is. I want to add it automatically when the user greate a new "object" of type project from the gui.

Thanks

Hi sunettew1,

For this requirement, you could use References.AddProject method.

More information, please refer to:

# References.AddProject Method

http://msdn.microsoft.com/en-us/library/vslangproj.references.addproject.aspx

On the other hand, there are some link about load assembly that may benefit you:

# Reference Interface

http://msdn.microsoft.com/en-us/library/vslangproj.reference(v=vs.120).aspx

# EnvDTE – Adding a reference to a project

http://blogs.msdn.com/b/murat/archive/2008/07/30/envdte-adding-a-refernce-to-a-project.aspx

# Using reflection to load unreferenced assemblies at runtime

http://www.dreamincode.net/forums/topic/78974-using-reflection-to-load-unreferenced-assemblies-at-runtime/

Best Regards

Starain

[RESOLVED]Determine if button was pressed on page

I have an issue with telling if the user has pressed submit due to the fact the page is automatically posting back when a dropdown value is changed.

Bit of history regarding the form, I have three dropdown’s called ParentCategories, SubCategories and ChildCategories

When the user chooses a ParentCategory the page auto postback to the controller to obtain the sub categories associated with the ParentCategorie and same for when the user chooses a SubCategory. my issue is this when the categories are chosen I’m trying
to display a button so the user can press it and create a new item but when I click that it posts back to the same controller which the dropdowns do.

How can I determine if the button was pressed, below is my form

 @using (Html.BeginForm("New", "Advert", FormMethod.Post, new { @class = "form-horizontal", @id = "ListingForm" }))
                                {
                                    <div class="step-content pos-rel" id="step-container">
                                        <div class="col-md-4 catergoiesLayout">
                                            <div class="col-lg-10">
                                                @Html.DropDownListFor(x => x.SelectedParentCategoryId, Model.ParentCategory, new { @ID = "drpParentCategories", @class = "form-control", size = "7", @style = "width:300px", onchange = "this.form.submit();" })
                                            </div>
                                        </div>
                                        <div class="col-md-4 catergoiesLayout" style="visibility: @Model.SubCategory != null ? true : false">
                                            <div class="col-lg-10">
                                                @if (Model.SubCategory != null)
                                                {
                                                    @Html.DropDownListFor(x => x.SelectedSubCategoryId, Model.SubCategory, new { @ID = "drpSubCategories", @class = "form-control", size = "7", @style = "width:300px", onchange = "this.form.submit();" })
                                                }
                                            </div>
                                        </div>
                                        <div class="col-md-4 catergoiesLayout" style="visibility: @Model.ChildCategory != null ? true : false">
                                            <div class="col-lg-10">
                                                @if (Model.ChildCategory != null)
                                                {
                                                    @Html.DropDownListFor(x => x.SelectedChildCategoryId, Model.ChildCategory, new { @ID = "drpChildCategories", @class = "form-control", size = "7", @style = "width:300px" })
                                                }
                                            </div>
                                        </div>
                                    </div>
                                    <hr />
  
                                        <div class="wizard-actions">
                                            <button class="btn btn-success btn-next" data-last="Finish">
                                                Create
                                                <i class="ace-icon fa fa-arrow-right icon-on-right"></i>
                                            </button>
                                        </div>
                                }

this is my controller

  [HttpPost]
        public ActionResult New(ChooseCategoryViewModel model)
        {
            try
            {
            if(buttonPressed){ // How can I check? 

                  //Go somewhere else if its pressed

             }
           else{
                AddressCompleted();

                model = BuildCategoryViewModel(model.SelectedParentCategoryId, model.SelectedSubCategoryId);
              }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return View(model);
        }

Add name and value attributes to your button:

<button class="btn btn-success btn-next" name="ButtonPressed" value="true" data-last="Finish">
    Create
    <i class="ace-icon fa fa-arrow-right icon-on-right"></i>
</button>

Then add a matching bool property to your ChooseCategoryViewmodel

public bool ButtonPressed {get;set;}

Then check the value in your controller:

try
{ 
    if(model.ButtonPressed)
    {
         // it was clicked

[RESOLVED]Issue with URL when posting back

Hello, I have an Ajax form on my page, when i choose something from the dropdown I’m Automatically posting the form back to the controller to retrieve additional information thats associated with the chosen value.

Here is how my page is laid out.

@using (Ajax.BeginForm("New", "Item", new AjaxOptions { HttpMethod = "POST" }, new { @class = "form-horizontal", @id = "Form" }))
                                {
                                    <div class="step-content pos-rel" id="step-container">
                                        <div class="col-md-4 catergoiesLayout">
                                            <div class="col-lg-10">
                                                @Html.DropDownListFor(x => x.SelectedValueId, Model.SomeCategory, new { @ID = "drpSomeItems", @class = "form-control", size = "7", @style = "width:300px", onchange = "this.form.submit();" })
                                            </div>
                                        </div>
                                    </div>
                                    <hr />
                                    <div class="wizard-actions">
                                        <button class="btn btn-prev">
                                            <i class="ace-icon fa fa-arrow-left"></i>
                                            Save
                                        </button>
                                    </div>
                                }

when the value changes and posts back my URL looks like this

http://localhost:1470/item/new?Length=6

but I want it to look like

http://localhost:1470/item/new

my controller looks like this

 [HttpPost]
        public ActionResult New(ChooseCategoryViewModel model)
        {



return view(model);
}

There’s no overload of the Ajax.Beginform method that takes string, string, AjaxOptions, object (http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.beginform%28v=vs.118%29.aspx).
You probably want the second-to-last overload and need to pass null to the routevalues parameter:

@using (Ajax.BeginForm("New", "Item", null, new AjaxOptions { HttpMethod = "POST" }, new { @class = "form-horizontal", id = "Form" }))

You also don’t need the @ in front of "id". You only need it before "class" because it is a C# keyword and cannot be used as a property name unless it is escaped with the @ sign: http://msdn.microsoft.com/en-us/library/x53a06bb.aspx

Visual Studio undoes change to View on publish

I am programming in VS 2012 Pro, using MVC 4 EF 5.  I changed a table in the database to remove a field.  The entity was updated in the model.  However one view was still using that field.  I deleted all references to that field in the view.  I did a rebuild. 
All successful.  Then I did a publish.  Suddenly Visual Studio reports that the file was changed outside of reader do you want to reload.  When I clicked yest suddenly the two lines are back in the view and the publish throws an error saying it can’t find
those fields.  It did this five times.  I tried explicitly clicking save and save all before doing the build.  I tried doing the rebuild as release. I tried doing the save then closing and re-opening VS 2012 Pro.

No avail.  It still kept putting those two lines back in and then failing because of the existence of those two lines.  This was only happening on publish, not on build or rebuild.

Then suddenly on the sixth attempt everything worked fine just like it was supposed. 

But just because it is working now doesn’t mean it won’t happen again.  So does anyone know what was happening and how I can make it stop if (or when), it happens again?

Well this never happened to me. It seems a glitch. Unless you reproduce it again, it is hard to find what the problem is.

Hi,

The publish method being? I’m not using FTP but to me it would look like some kind of sync issue. Something such as a file on the FTP site found to be more recent than the one you changed ???

You could also try the procmon tool at sysinternals to trace some details about how the file is overwritten… A VS forum might be better…

PatriceSc

The publish method being?

On the menu bar select BuidlPublish [ProjectName] which opens the publish wizard.  Surely you are not putting files with source code on your servers? 

PatriceSc

I’m not using FTP but to me it would look like some kind of sync issue.

 I don’t use FTP either.  Never have.  Our sites are hosted by the department’s servers. 

The Publish event takes place all on the developing machines.  The servers have nothing to do with it.  The publish wizard is set to replace all files in the deployment package.

The thing is that the file seems to be overwritten with a previous version. So I’m trying to understand from which location this old version could come from (or a local "cache" or "recovery" folder, if you can test for this, see perhaps if it does this everywhere
or just on a particular machine)?

At this point I would try the procmon tool at sysinternals (at
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
) to see how this file is overwritten…

PatriceSc

The thing is that the file seems to be overwritten with a previous version.

So I figured.

PatriceSc

So I’m trying to understand from which location this old version could come from

Which is why I started this thread.

PatriceSc

if you can test for this, see perhaps if it does this everywhere or just on a particular machine

Two problems with this are 1. It’s not doing it any more.  2.  There are no hardware resources for me to copy my project to another machine with Visual Studio on it.  Other machines available for that kind of testing do not exist.

Create View Wizard's scaffolding does not construct View

For the last two weeks, whenever I use the wizard to create a Details, Edit or Create strongly typed view with scaffolding with the wizard, I get an essentially empty view.

All the Edit and Create contain are the BeginForm, the submit, and the back to list link.  Yet just three weeks ago I was able to generate all the fields in the model with the create view wizard when using scaffolding with a strongly typed model and the
Edit or Create template,  I would get a view displaying all of the fields in the model with the proper editor helpers.

This is an example of what I am doing.

  1. I right click on the controller Edit function for which I am creating the view.
  2. I select add view.
  3. I check the the Name in the wizard’s ViewName box so ensure that it is for the proper view (Edit, Create, or Delete).
  4. I check the Create a Strongly Typed View checkbox
  5. I select the model from the model class drop down.
  6. I select the scaffolding template Edit from the Scaffolding template drop down.
  7. I leave the Reference Script Libraries  checkbox checked.
  8. I leave the use layout or master page checkbox checked.
  9. Since the specific Layout page is set in the _ViewStart.cshtml file, I do not show it in the text box.
  10. I click "Add".

Then a n Edit view is created that contains only the Html.BeginForm helper, the submit button and the "Back to List" Action link.

Three weeks ago it properly generated Editor helpers for every field in the model.  But not any more.

Does anyone know what happened?

Hi joeller,

Thank you post the issue to asp.net forum.

It seems your edit template not work good when you select to create editor view.

You can create a new mvc project and try it again see if it works fine in the new project.

Please make sure your EditorTemplate file correctly in your project. Create directory EditorTemplates in Views/Shared and you

should create a view with the same name as the model you want to create the editor for.

http://msdn.microsoft.com/en-us/magazine/ee291528.aspx

Thanks.

Best Regards!

I read Scott’s article. My Common7IDE folder does not have an ItemTemplates folder. All it has is "Script Diagnostics". Any idea where it may be?

Regarding the creation of a directory.  Are you asking me to create the Edit, Create, Display, and Index templates for each controller myself in my project?  As I understand it, the reason for these templates is to make it easy to create the Edit, Create,
Display, and Index views.  If I have to make the templates myself, how is that making it easy?   I may as well just do the views myself.

If the templates are supposed to be in that folder under Common7IDE how do I get that folder?

joeller

If the templates are supposed to be in that folder under Common7IDE how do I get that folder?

Hi joeller,

Thank you for the feedback.

Generately, the template files in below directory.

Microsoft Visual Studio…Common7IDEItemTemplatesCSharpWebMVC 4CodeTemplatesAddViewCSHTML

Thanks.

Fuxiang Zhang – MSFT

Generately, the template files in below directory.

Microsoft Visual Studio…Common7IDEItemTemplatesCSharpWebMVC 4CodeTemplatesAddViewCSHTML

Edward Joell MCSD

My Common7IDE folder does not have an ItemTemplates folder. All it has is "Script Diagnostics". Any idea where it may be?

 

As stated earlier there is no such folder on this machine..

Fuxiang Zhang – MSFT

You can create a new mvc project and try it again see if it works fine in the new project.

It works fine in other MVC projects.  So this behavior is only with this project.

And now to add insult to injury, I can not add a controller to this project.  I get the error "Object reference not set to instance of Object."

[RESOLVED]CreateUserWizard within a jQuery dialog

Hi,

I place a createUserWizard insode a jQuery dialog, 

When clicking the "Create User" nothing happens….

Any idea why id does not work from withinh a dialog ?

Hi shtrudel,

For your issue ,I think the problem is that you didn’t append your dialog to your form,please try the code below:

 $(function () {
            $("#divId").dialog({
                autoOpen: true
            }).parent().appendTo("form");
        })

Best Regards,

Kevin Shen.

You can actually use the
appendTo option
.

$(function () {
     $("#divId").dialog({
         autoOpen: true,
         appendTo: "form:first"
     })
})

One record not inserted into SQL

Hi,

I need help regarding the computation of birthdate that whatever month, day and year the user selects the system will display the computed age of that person. I have the JS and CSS files for those and added an <ajaxToolkit:CalendarExtender …> control to
display the calendar wizard. The only problem I experience here is that whenever I choose the calendar wizard as shown on the image URL and save the record by pressing the save button the computed age suddenly clears out even though I didn’t use to clear the
textbox of that age value.

Could anyone explain why it happens that way? I might not be able to appropriately apply the right approach somewhere in my code.

Image URLs:         

http://imageshack.us/photo/my-images/33/9b76.jpg/                    

http://imageshack.us/photo/my-images/534/fylo.jpg/

 

Please help. Thanks.

i think you are using label control to display age using javascript. But label text gets cleared off on postback. So you need to using a read only textbox with no borders so that it looks as if its a label control.

Refer this link for solution

http://forums.asp.net/post/2977001.aspx

hello hey, yes i am aware that label does not throw a value but only textbox. 

here’s my asp.net for textbox age:

<asp:TextBox ID="tbage" runat="server" CssClass="txtbox" Height="12px" Width="40px" BorderStyle="None"

Font-Size="X-Small" Enabled="false"></asp:TextBox>

is it working with textbox now??

unfortunately, it’s still not working.